如何让 git 从分支而不是标签中拉取?
How to let git pull from branch not from tag?
我们的 repo 恰好有一个与分支名称同名的标签。因此,当我尝试从该分支中拉出时,git 感到困惑并从标签中拉出,就像这样。我必须先删除该标签才能使我的 git 拉动工作。
那么我如何告诉 git 从分支而不是标签拉取?
cc-backend ➤ git pull origin 0.9.0-rc6-patch1
From 10.0.0.28:webcc/cc-backend
* tag 0.9.0-rc6-patch1 -> FETCH_HEAD
Already up to date.
/* I have to delete that tag and git pull again to get the result I want */
cc-backend ➤ git pull origin 0.9.0-rc6-patch1
From 10.0.0.28:webcc/cc-backend
* branch 0.9.0-rc6-patch1 -> FETCH_HEAD
Updating 9d7e9dc3..2bf3f96a
Fast-forward
app/Services/GroupSeat/Seat.php | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
你应该使用全名
git checkout refs/heads/<branchname>
或用于标签
git checkout refs/tags/<refname>
拉
git pull origin refs/heads/<branchname>
要访问相关文档,请输入
git help revisions
参考SPECIFYING REVISIONS
部分
默认情况下,获取引用规范是 fetch = +refs/heads/*:refs/remotes/origin/*
因此您还可以 git fetch
(获取所有分支),然后将您的分支与 origin/<remote branch>
合并或变基
但更方便的解决方法是就标签的命名约定达成一致:v0.9.0-rc6-patch1
而不是 0.9.0-rc6-patch1
。那样,就没有更多的 mix-up.
远程仓库似乎有一个标签和一个同名的分支0.9.0-rc6-patch1
。使用全称fetch/pull,
# fetch/pull the tag
git fetch/pull origin refs/tags/0.9.0-rc6-patch1
# fetch/pull the branch
git fetch/pull origin refs/heads/0.9.0-rc6-patch1
我们的 repo 恰好有一个与分支名称同名的标签。因此,当我尝试从该分支中拉出时,git 感到困惑并从标签中拉出,就像这样。我必须先删除该标签才能使我的 git 拉动工作。
那么我如何告诉 git 从分支而不是标签拉取?
cc-backend ➤ git pull origin 0.9.0-rc6-patch1
From 10.0.0.28:webcc/cc-backend
* tag 0.9.0-rc6-patch1 -> FETCH_HEAD
Already up to date.
/* I have to delete that tag and git pull again to get the result I want */
cc-backend ➤ git pull origin 0.9.0-rc6-patch1
From 10.0.0.28:webcc/cc-backend
* branch 0.9.0-rc6-patch1 -> FETCH_HEAD
Updating 9d7e9dc3..2bf3f96a
Fast-forward
app/Services/GroupSeat/Seat.php | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
你应该使用全名
git checkout refs/heads/<branchname>
或用于标签
git checkout refs/tags/<refname>
拉
git pull origin refs/heads/<branchname>
要访问相关文档,请输入
git help revisions
参考SPECIFYING REVISIONS
部分
默认情况下,获取引用规范是 fetch = +refs/heads/*:refs/remotes/origin/*
因此您还可以 git fetch
(获取所有分支),然后将您的分支与 origin/<remote branch>
但更方便的解决方法是就标签的命名约定达成一致:v0.9.0-rc6-patch1
而不是 0.9.0-rc6-patch1
。那样,就没有更多的 mix-up.
远程仓库似乎有一个标签和一个同名的分支0.9.0-rc6-patch1
。使用全称fetch/pull,
# fetch/pull the tag
git fetch/pull origin refs/tags/0.9.0-rc6-patch1
# fetch/pull the branch
git fetch/pull origin refs/heads/0.9.0-rc6-patch1