Upload a new Github Repo from the command line

1. create the repo via curl

Replace <this>:

2. upload

Assuming you’ve created your git repo locally, added and committed then:

3. check

It should be at:

warning: deleting branch ‘old_branch’ that has been merged to ‘refs/remotes/origin/old_branch’, but not yet merged to HEAD: why I hate/love git

git is immensely powerful. In the same way that English is as a language. There are endless nuances.

I love that you can do so much with it.

However, I hate that, even after a decade using it, I’m still running into basic issues that interrupt my workflow while I go and research the error message to see what’s going on under the hood.

Here’s an example. I was so confident I could delete the local branches I did two at once. And ran into 2 separate error messages. i.e. I did a git branch -d <local_branch1 local_branch2> that had been pushed and merged only to get these messages:

A. warning: deleting branch 'old_branch' that has been merged to 'refs/remotes/origin/old_branch', but not yet merged to HEAD.

Turns out, when you do a merge --squashand delete the remote branch you’ll get this warning. Here’s why:

  1. you created the branch
  2. pushed to remote
  3. merged there and deleted the remote branch
  4. did a pull from origin/master
  5. your local HEAD (master) does not have a record of this merge (even though it was done on the remote) hence the warning



Check with:



Diffs between working directory and staged

Say you have modified files README.md and code.c.

You’ve added README.md to the index (i.e. git add README.md) but code.cis still in the Working Directory.


git diff will only show the diff for code.c

To see the diff for README.md use:

git diff --staged

Now, if we change README.mdagain, this change is in the working directory.

Note: --cached is synonymous with --staged.




git plumbing: cat-file

Digging into git a bit more.

cat-file is part of git’s plumbing. Here’s what it shows. If we use:

git cat-file -p head

to show the contents of the latest commit object.

Note: https://stackoverflow.com/questions/2304087/what-is-head-in-git

Then to see details of the tree object you’d use:

git cat-file -p <sha1 of tree>

which shows the contents of the working directory.

And to see the contents of the file itself you’d use the sha1 of the blob. E.g.

git cat-file -p <sha1 of blob>

Note that the blob is the entire contents of the file NOT just a diff.


Oh My Zsh

Thought I’d give this a go.

From https://ohmyz.sh/

  1. install zsh (on the Mac this is already installed)
  2. set iTerm2 to use this (chsh -s $(which zsh) and in iTerm2 > Preferences > Profiles > Default > General, set the Command to /bin/zsh instead of Login shell
  3. Install Oh My Zsh. i.e. sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" –  https://ohmyz.sh/
  4.  If you’re using the agnoster theme, then be aware you’ll need to use Patched fonts (not a big thing but just make sure you install both ASCII and non-ASCII fonts) – https://github.com/powerline/fonts
  5. The most time-consuming stuff was customisation. Copy chosen theme to ~/.oh-my-zsh/custom/themes/agnoster.zsh-theme and customise.


# Dir: current working directory
prompt_dir() {
prompt_segment blue black &quot; <code>basename ${PWD/#$HOME/'~'}</code> &quot;


prompt_segment blue black '%c'


E.g. no user@host in command prompt:



in your zshrc file.



See also



And on the agnoster theme:

  1. red cross means last command had a non-zero exit code: https://github.com/agnoster/agnoster-zsh-theme/issues/54

And a Zsh Cheat Sheet:



git shortcuts such as:

gst: git status

ga: git add

gcam: git commit -m

gp: git push

gpsup:git push –set-upstream origin $(current_branch)