博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Git pull 小结
阅读量:4038 次
发布时间:2019-05-24

本文共 1911 字,大约阅读时间需要 6 分钟。

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

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

 
1
[branch
"
master
"
]
2
remote
=
origin
3
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 to
11
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.git
2
git config branch.master.remote origin
3
git config branch.master.merge refs
/
heads
/
master
 
 

 

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

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

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

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

 
 
1
[branch
"
master
"
]
2
remote
=
origin
3
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
=
origin
3
merge
=
refs
/
heads
/test1

转载地址:http://vnpdi.baihongyu.com/

你可能感兴趣的文章
autoupdate script
查看>>
linux 驱动开发 头文件
查看>>
/etc/resolv.conf
查看>>
container_of()传入结构体中的成员,返回该结构体的首地址
查看>>
linux sfdisk partition
查看>>
ipconfig,ifconfig,iwconfig
查看>>
opensuse12.2 PL2303 minicom
查看>>
网络视频服务器移植
查看>>
Encoding Schemes
查看>>
移植QT
查看>>
如此调用
查看>>
计算机的发展史
查看>>
带WiringPi库的交叉编译如何处理一
查看>>
带WiringPi库的交叉笔译如何处理二之软链接概念
查看>>
Spring事务的七种传播行为
查看>>
ES写入找不到主节点问题排查
查看>>
Java8 HashMap集合解析
查看>>
欢迎使用CSDN-markdown编辑器
查看>>
Android计算器实现源码分析
查看>>
Android系统构架
查看>>