mar*_*ful 181 git git-checkout
我有时会使用该checkout -b选项创建一个新分支,同时检查它并在一个命令中设置跟踪.
在新环境中,我收到此错误:
$ git checkout -b test --track origin/master
fatal: Cannot update paths and switch to branch 'test' at the same time.
Did you intend to checkout 'origin/master' which can not be resolved as commit?
Run Code Online (Sandbox Code Playgroud)
为什么Git不喜欢它?这曾经使用相同的回购.
Von*_*onC 191
'
origin/master'无法解决为提交
奇怪:你需要检查你的遥控器:
git remote -v
Run Code Online (Sandbox Code Playgroud)
并确保origin获取:
git fetch origin
Run Code Online (Sandbox Code Playgroud)
然后:
git branch -avv
Run Code Online (Sandbox Code Playgroud)
(看看你是否有origin/master分支)
Lud*_*der 73
FWIW:如果你的分支机构中有拼写错误,你会得到同样的错误.
Bob*_*man 53
您可以在上下文中获取此错误,例如Travis构建,默认情况下,检查代码git clone --depth=50 --branch=master.据我所知,你可以控制--depth通过.travis.yml,但不是--branch.由于这导致只有一个分支被遥控器跟踪,您需要独立更新遥控器以跟踪所需的遥控器的参考.
之前:
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
Run Code Online (Sandbox Code Playgroud)
修复:
$ git remote set-branches --add origin branch-1
$ git remote set-branches --add origin branch-2
$ git fetch
Run Code Online (Sandbox Code Playgroud)
后:
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/branch-1
remotes/origin/branch-2
remotes/origin/master
Run Code Online (Sandbox Code Playgroud)
小智 19
这个简单的事对我有用!
如果它说它不能同时做两件事,那就将它们分开.
git branch branch_name origin/branch_name
git checkout branch_name
Run Code Online (Sandbox Code Playgroud)
遇到这个问题时,您可以按照以下步骤操作:
git远程显示来源
输出这个:
Run Code Online (Sandbox Code Playgroud)remote origin Fetch URL: <your_git_path> Push URL: <your_git_path> HEAD branch: development Remote branches: development tracked Feature2 tracked master tracked refs/remotes/origin/Feature1 stale (use 'git remote prune' to remove) Local branches configured for 'git pull': Feature2 merges with remote Feature2 development merges with remote development master merges with remote master Local refs configured for 'git push': Feature2 pushes to Feature2 (up to date) development pushes to development (up to date) master pushes to master (local out of date)
Run Code Online (Sandbox Code Playgroud)» git remote update Fetching origin From gitlab.domain.local:ProjectGroupName/ProjectName * [new branch] Feature3 -> Feature3
如您所见,新分支已从远程获取.
3.最后,使用此命令检出分支
Run Code Online (Sandbox Code Playgroud)» git checkout -b Feature3 origin/Feature3 Branch Feature3 set up to track remote branch Feature3 from origin. Switched to a new branch 'Feature3'
没有必要明确告诉Git使用远程跟踪(使用--track)分支.
上面的命令将设置本地分支以从源跟踪远程分支.
| 归档时间: |
|
| 查看次数: |
125299 次 |
| 最近记录: |