我有了另一个远程回购upstream之外origin.我能做到git checkout origin/master,但是当我跑步时git checkout upstream/master,我得到:
error: pathspec 'upstream/master' did not match any file(s) known to git.
Run Code Online (Sandbox Code Playgroud)
这也不起作用:
$ 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?
Run Code Online (Sandbox Code Playgroud)
如何在upstream远程检查远程分支origin?我的git版本是2.1.2.
mu *_*u 無 34
只需从远程获取refs(这将获取上游repo的所有分支,提交,引用等)
git fetch upstream
Run Code Online (Sandbox Code Playgroud)
在此之后,签出所需的分支(这将创建分支的本地副本)
git checkout -b <branchname> --track upstream/<branchname>
Run Code Online (Sandbox Code Playgroud)
现在,如果您希望将来在此分支中进行更改,您需要做的就是
git pull upstream <branchname>
Run Code Online (Sandbox Code Playgroud)
如前所述这里,尝试做的分支名明确的获取:
git fetch upstream master:branch_name
Run Code Online (Sandbox Code Playgroud)
如果您只是添加了遥控器,则需要添加fetch它,以便Git知道哪些分支可用:
git fetch upstream master
Run Code Online (Sandbox Code Playgroud)
之后,您可以做
git checkout upstream/master
Run Code Online (Sandbox Code Playgroud)
没有任何问题。