I've looked at a few questions here, notably this one but I'm still confused.
I have a server set up with a slow up-link that I access through an SSH tunnel. On it, I cloned a bare repository of the Linux kernel (origin points to kernel.org). I then cloned the bare repository on my home machine, checked out tag, created a branch ('test' say), made changes on that branch and finally pushed the changes to the bare repo on my server.
Now I'm at a client site and want to checkout the branch. To avoid my slow uplink at the client site, I cloned the linux repo from the kernel.org and changed 'origin' to point to my server via the SSH tunnel. I can see the branch, but can't check it out:
~/linux-3.0.y$ git version
git version 1.7.0.4
~/linux-3.0.y$
~/linux-3.0.y$ git status
# On branch master
nothing to commit (working directory clean)
~/linux-3.0.y$
~/linux-3-0.y$ git remote show origin
git-user@localhost's password:
* remote origin
Fetch URL: git+ssh://git-user@localhost:48884/home/git-user/linux-3.0.y
Push URL: git+ssh://git-user@localhost:48884/home/git-user/linux-3.0.y
HEAD branch: master
Remote branches:
test new (next fetch will store in remotes/origin)
master new (next fetch will store in remotes/origin)
Local ref configured for 'git push':
master pushes to master (up to date)
~/linux-3.0.y$
~/linux-3.0.y$ git checkout -b test origin/test
fatal: git checkout: updating paths is incompatible with switching branches.
Did you intend to checkout 'origin/test' which can not be resolved as commit?
What I actually intended was to be able to work on the branch created at home at my client's site. What should I do (have done) to checkout this branch?
Well first, it seems that you didn't fetch the branches.
Use git branch -a
instead of git remote show origin
.
If the test branch is missing, then do git fetch --all
.
Now if you want to checkout a remote branch as a local branch with the same name, just do git checkout BRANCH_NAME
, it will be automatically set up to track the origin.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With