git 如何将本地 master 拉入本地分支
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39598875/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to pull local master into local branch
提问by Stophface
I have a remote origin/master
and a remote branch remote_branch
.
I also have local master
and a local branch local_branch
. When I try to pull the local master
into the local_branch
with git pull master local_branch
I get this.
我有一个远程origin/master
和一个远程分支remote_branch
。我也有本地master
和本地分支local_branch
。当我尝试将本地拉master
入local_branch
with 时,git pull master local_branch
我得到了这个。
fatal: 'master' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
However, when I do git branch
I see this:
但是,当我这样做时,git branch
我看到了:
* loca_branch
master
Why can't I pull from my local master
?
为什么我不能从我的本地拉master
?
回答by SantiG
merge changes from local_branch TOmaster
将 local_branch 的更改合并到master
git checkout master
git merge local_branch
merge changes from master TOlocal_branch
合并从 master到local_branch 的更改
git checkout local_branch
git merge master
Pull is when you have an 'origin' repo :)
拉是当你有一个“原点”repo 时 :)
回答by Shmulik Klein
git pull
is an alias for git fetch && git merge
you cannot fetch from local branches (only from remotes) - actually you don't need to, if your intention is to merge master
into local_branch
, just use git merge master
when you are on local_branch
.
git pull
是一个别名,因为git fetch && git merge
您无法从本地分支(仅从远程)获取 - 实际上您不需要,如果您打算合并master
到local_branch
,只需git merge master
在您打开时使用local_branch
。
回答by Vampire
As the error message says, master
is not a repository it knows of. This is because with git pull master local_branch
you say "Fetch the branch local_branch
from remote repository master
and merge it into my currently checked-out branch".
正如错误消息所说,master
不是它知道的存储库。这是因为git pull master local_branch
您说“local_branch
从远程存储库中获取分支master
并将其合并到我当前签出的分支中”。
But that is not what you are after. You want to say "Merge my local branch master
into my local branch local_branch
, checking it out if it is not already" and that would be git checkout local_branch && git merge master
但这不是你所追求的。您想说“将我的本地分支合并master
到我的本地分支local_branch
,如果尚未合并,请检查它”,那就是git checkout local_branch && git merge master