Git Orphan branch "This branch is 1 commit ahead, n commits behind master"

379 Views Asked by At

I've used the following to create an orphan branch on a local repo, then pushed it to a remote on Github:

git checkout --orphan worker
git rm -rf .
git commit --allow-empty -m "Initial orphan commit"
git push origin worker

I get the "This branch is 1 commit ahead, n commits behind master" message while on the worker branch on GitHub.

The idea here is to create an empty, unrelated branch with no history, totally disconnected from all the other branches and commits and, that isn't tracked in relation to the master branch.

1

There are 1 best solutions below

1
On BEST ANSWER

You've done so. GitHub's message is basically meaningless in this case. Your branch has 1 commit that isn't in master, and master has n commits that aren't in your branch. GitHub should probably suppress that message when there is no common ancestor, but it looks like it doesn't :)