配置 git 以便“git pull”而不是“git pull origin master”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4297795/
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
configure git so that "git pull" instead of "git pull origin master"?
提问by munchybunch
Using git pull
used to pull from the remote repository as expected - now, it's asking me to use git pull origin master
. I don't quite understand the instructions it's giving me, saying I can add something to my configuration file:
使用git pull
用于按预期从远程存储库中提取 - 现在,它要求我使用git pull origin master
. 我不太明白它给我的说明,说我可以在我的配置文件中添加一些内容:
[branch "master"]
remote = <nickname>
merge = <remote-ref>
[remote "<nickname>"]
url = <url>
fetch = <refspec>
Right now my configuration file looks like
现在我的配置文件看起来像
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
[remote "origin"]
url = |redacted|
fetch = +refs/heads/*:refs/remotes/origin/*
So I'm guessing I need to add
所以我想我需要添加
[branch "master"]
remote = origin
merge = ??
What does "merge" need as its argument? What's a remote-ref(erence?)? I tried looking at http://git-scm.com/docs/git-configbut it seems to be more about the command itself.
“合并”需要什么作为其论点?什么是远程引用(erence?)?我尝试查看http://git-scm.com/docs/git-config但它似乎更多地与命令本身有关。
Thanks in advance!
提前致谢!
采纳答案by Horia Dragomir
try:
尝试:
[branch "master"]
remote = origin
merge = refs/heads/master
回答by svick
It should be enough just to execute
执行应该就够了
git config branch.master.remote origin
回答by Jonathan Zrake
Just do:
做就是了:
git branch --set-upstream master origin/master
回答by jilles
An easy way is to use git checkout -t
to have the tracking set up when you create the local branch.
一种简单的方法是git checkout -t
在创建本地分支时使用跟踪设置。