fatal: The upstream branch of your current branch does not match the name of your current branch

This happens if the name of the upstream branch and local branch do not match, which sometimes happens, and usually is unwanted: > git status On branch release-1.2.3 Your branch is up to date with ‘origin/master’. To solve this, run: git branch –unset-upstream Then, once you run git push again, you will be asked to … Read more

Listing each branch and its last revision’s date in Git

commandlinefu has 2 interesting propositions: for k in $(git branch | perl -pe s/^..//); do echo -e $(git show –pretty=format:”%Cgreen%ci %Cblue%cr%Creset” $k — | head -n 1)\\t$k; done | sort -r or: for k in $(git branch | sed s/^..//); do echo -e $(git log –color=always -1 –pretty=format:”%Cgreen%ci %Cblue%cr%Creset” $k –)\\t”$k”;done | sort That is … Read more

How do you remove an invalid remote branch reference from Git?

You might be needing a cleanup: git gc –prune=now or you might be needing a prune: git remote prune public prune Deletes all stale tracking branches under <name>. These stale branches have already been removed from the remote repository referenced by <name>, but are still locally available in “remotes/<name>”. With –dry-run option, report what branches … Read more

What are the differences between git remote prune, git prune, git fetch –prune, etc

I don’t blame you for getting frustrated about this. The best way to look at is this. There are potentially three versions of every remote branch: The actual branch on the remote repository (e.g., remote repo at https://example.com/repo.git, refs/heads/master) Your snapshot of that branch locally (stored under refs/remotes/…) (e.g., local repo, refs/remotes/origin/master) And a local … Read more

How can I clone all remote branches?

First, clone a remote Git repository and cd into it: $ git clone git://example.com/myproject $ cd myproject Next, look at the local branches in your repository: $ git branch * master But there are other branches hiding in your repository! See these using the -a flag: $ git branch -a * master remotes/origin/HEAD remotes/origin/master remotes/origin/v1.0-stable … Read more

How do I clone all remote branches?

First, clone a remote Git repository and cd into it: $ git clone git://example.com/myproject $ cd myproject Next, look at the local branches in your repository: $ git branch * master But there are other branches hiding in your repository! See these using the -a flag: $ git branch -a * master remotes/origin/HEAD remotes/origin/master remotes/origin/v1.0-stable … Read more

Why does Git tell me “Not currently on any branch” after I run “git checkout origin/”?

The output of git status indicates that your working directory is clean; good. Now, by running git checkout origin/web-zach you are attempting to check out a remote-tracking branch, called origin/web-zach; it’s a special type of branch, local to your repo, that keeps track of the corresponding branch, web-zach, living in the remote repository called origin. … Read more