打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Git pull 小结

当git clone之后,直接git pull它会自动匹配一个正确的remote url

是因为在config文件中配置了以下内容:

1 [branch "master"]2 remote = origin3 merge = refs/heads/master

表明:

1.git 处于master这个branch下时,默认的remote就是origin;

2.当在master这个brach下使用指定remote和merge的git pull时,使用默认的remote和merge。

 

但是对于自己建的项目,并用push到远程服务器上,并没有这块内容,需要自己配置

如果直接运行git pull,会得到如此结果:

 

1 $ git pull 2 Password: 3 You asked me to pull without telling me which branch you 4 want to merge with, and 'branch.master.merge' in 5 your configuration file does not tell me, either. Please 6 specify which branch you want to use on the command line and 7  try again (e.g. 'git pull <repository> <refspec>'). 8 See git-pull(1) for details. 9 10 If you often merge with the same branch, you may want to11 use something like the following in your configuration file:12 13 [branch "master"]14 remote = <nickname>15 merge = <remote-ref>16 17 [remote "<nickname>"]18 url = <url>19 fetch = <refspec>20 21 See git-config(1) for details.

在参考[2]中,有这样一段:

Note: at this point your repository is not setup to merge _from_ the remote branch when you type 'git pull'. You can either freshly 'clone' the repository (see "Developer checkout" below), or configure your current repository this way:

1 git remote add -f origin login@git.sv.gnu.org:/srv/git/project.git2 git config branch.master.remote origin3 git config branch.master.merge refs/heads/master   

 

因此通过git config进行如下配置:

1 $ git config branch.master.remote origin2 $ git config branch.master.merge refs/heads/master

或者加上--global选项,对于全部项目都使用该配置。


执行完以上 命令,在config文件中配置了以下内容:

1 [branch "master"]2 remote = origin3 merge = refs/heads/master


============================

假如 当前 仓库有 两个 分支,master 和 test1,当我们 执行了 以下 两条命令之后:


git config branch.test1.remote origin

git config branch.test1.merge refs/heads/test1


将在 在config文件中配置了以下内容:

1 [branch "test1"]2 remote = origin3 merge = refs/heads/test1











本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
The current branch is not configured for pull No value for key branch.master.merge found in configur
Git远程分支和refs文件详解
git push用法和常见问题分析
GIT 的基本使用-常用命令
git之Pushing to the remote branch is not fast-forward错误解决
Git笔记-进阶
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服