Drop Shadow Drop Shadow - 1 month ago 19
Git Question

How to checkout remote branch git?

Me and my team member are working on same repository. Someone create a branch from master called test_01, worked on that and commit, push to test_01 and merge to master. In the meantime some commit are done in master. Now I want to checkout that test_01 so that I write

git checkout test_01


and got a git error : pathspec 'test_01' did not match any file know to git .

Answer

After a git fetch, check the list of the remote tracking branches with:

git branch -avv

If you see origin/test_01, a git checkout test_01 should work, since it is the equivalent of:

git checkout -b <branch> --track <remote>/<branch>

But since it does not work, it is likely the test_01 branch was merged to master locally by the other developer, and only master was pushed.
You can try and look for the commit of that unnamed branch merged into master: see "Find merge commit which include a specific commit".

Comments