Place an order on another remote device

I have a repo that has another remote upstream besides origin . I can do git checkout origin/master , but when I run git checkout upstream/master , I get:

 error: pathspec 'upstream/master' did not match any file(s) known to git. 

This also does not work:

 $ git fetch upstream From https://github.com/getsentry/sentry * branch HEAD -> FETCH_HEAD $ git co -b asdf --track upstream/master fatal: Cannot update paths and switch to branch 'asdf' at the same time. Did you intend to checkout 'upstream/master' which can not be resolved as commit? 

How to check branches on upstream remote, how do I do on origin remote? My git version is 2.1.2.

+6
source share
2 answers

Just remove the links from the remote device (this will extract all the branches, commit, links, etc. for the upstream repo)

 git fetch upstream 

After that check the required branch (this creates a local copy of the branch)

 git checkout -b <branchname> --track upstream/<branchname> 

Now, if you want to make changes to this thread in the future, all you have to do is

 git pull upstream <branchname> 

As mentioned here , try explicitly fetching the branch name:

 git fetch upstream master:branch_name 
+13
source

If you just added a remote, you need to fetch it so that Git knows which branches are available:

 git fetch upstream master 

After that you can do

 git checkout upstream/master 

without any problems.

+3
source

Source: https://habr.com/ru/post/989184/


All Articles