I have cloned a repo using git. Another user created a new branch, call it foo (there are so two branches master and foo). I created another branch foo to track remote foo. So I ran this command : git branch –set-upstream foo origin/foo. But I have an error message telling me : fatal: Not a valid object name: 'origin/foo' Can anybody help ? When I run git remote origin show I have the message :
* remote origin
Fetch URL: ssh://***
Push URL: ssh://***
HEAD branch: foo
Remote branches:
master tracked
foo new (next fetch will store in remotes/origin)
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (local out of date)
you must first fetch or pull the branch up to your local repo.
After that, you can checkout
fooAnd, you could use the above command you wrote to track origin/foo with another local branch name (put in your call, just checkout as you use the same name anyway).
Git remote are only somewhere you can pull/push change. But in reality, all what git do is on your local drive, so you cannot interact with remote branch unless you fetch them first to your locale.
origin/foois only a label on asha-1commit id that you hold locally. When you useorigin/foo, you reference the local label, not the remote status (there’s no ssh connection made while referencing a remote branch).