*****git pull总结
当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
GIT PULL命令详解
http://www.yiibai.com/git/git_pull.html
git pull命令的作用是,取回远程主机某个分支的更新,再与本地的指定分支合并。它的完整格式稍稍有点复杂。
$ git pull <远程主机名> <远程分支名>:<本地分支名>
比如,取回origin主机的next分支,与本地的master分支合并,需要写成下面这样。
$ git pull origin next:master
如果远程分支是与当前分支合并,则冒号后面的部分可以省略。
$ git pull origin next
上面命令表示,取回origin/next分支,再与当前分支合并。实质上,这等同于先做git fetch,再做git merge。
$ git fetch origin
$ git merge origin/next
在某些场合,Git会自动在本地分支与远程分支之间,建立一种追踪关系(tracking)。比如,在git clone的时候,所有本地分支默认与远程主机的同名分支,建立追踪关系,也就是说,本地的master分支自动”追踪”origin/master分支。
Git也允许手动建立追踪关系。
git branch --set-upstream master origin/next
上面命令指定master分支追踪origin/next分支。
如果当前分支与远程分支存在追踪关系,git pull就可以省略远程分支名。
$ git pull origin
上面命令表示,本地的当前分支自动与对应的origin主机”追踪分支”(remote-tracking branch)进行合并。
如果当前分支只有一个追踪分支,连远程主机名都可以省略。
$ git pull
上面命令表示,当前分支自动与唯一一个追踪分支进行合并。
如果合并需要采用rebase模式,可以使用–rebase选项。
$ git pull --rebase <远程主机名> <远程分支名>:<本地分支名>
*****git pull总结的更多相关文章
- git pull和git fetch的区别
Git中从远程的分支获取最新的版本到本地有这样2个命令:1. git fetch:相当于是从远程获取最新版本到本地,不会自动merge Git fetch origin master git log ...
- 聊下git pull --rebase
有一种场景是经常发生的. 大家都基于develop拉出分支进行并行开发,这里的分支可能是多到数十个.然后彼此在进行自己的逻辑编写,时间可能需要几天或者几周.在这期间你可能需要时不时的需要pull下远程 ...
- Git fetch和git pull的区别
Git中从远程的分支获取最新的版本到本地有这样2个命令:1. git fetch:相当于是从远程获取最新版本到本地,不会自动merge git fetch origin mastergit log - ...
- git pull 冲突解决
这个意思是说更新下来的内容和本地修改的内容有冲突,先提交你的改变或者先将本地修改暂时存储起来. 处理的方式非常简单,主要是使用git stash命令进行处理,分成以下几个步骤进行处理. 1.先将本地修 ...
- git pull 然后 ahead of origin/master * commit 消失
本来显示 your branch is ahead origin/master * commit后来也许在master merge 这个分支后, 然后git pull, 就显示Your branch ...
- git pull提示当前不在某个分支上
$ git pull You are not currently on a branch, so I cannot use any 'branch.<branchname>.merge' ...
- git pull 和本地文件冲突问题解决
具体方法如下 git pull origin 分支 //出现错误 git stash 缓存起来 git pull origin 分支 git stash pop //还原 git stash cle ...
- git pull错误
1. Pull is not possible because you have unmerged files. 症状:pull的时候 $ git pull Pull is not possible ...
- 关于git中git pull --rebase中的一些坑
在公司里面,每次我更改完代码,准备pull最新代码时,总是会遇到各种各样的问题.,因为对应的问题不同,解决方法很多.但是比较通用的办法还是有的: git pull --rebase //报错时 g ...
- git merge git pull时候遇到冲突解决办法git stash
在使用git pull代码时,经常会碰到有冲突的情况,提示如下信息: error: Your local changes to 'c/environ.c' would be overwritten b ...
随机推荐
- 下拉框select chosen被遮盖
最简单的就是让容器高度大点. 用js调整也行. 为什么z-index不管事,看下面... 浏览器支持 所有主流浏览器都支持 z-index 属性. 注释:任何的版本的 Internet Explore ...
- XJOI NOIP模拟题2
第一题 组合计数 分析: 从前往后一位一位的计算 先算第一位比t小的数目,再算第一位与t[1]相同,第2位比t小的个数以此类推 先预处理一个数组h,h[i]表示从1~it串与s串不同的位数 对于第i位 ...
- CF762E Radio Stations
题目戳这里. 我还以为是KDtree呢,但是KDtree应该也可以做吧. 这是一道数据结构好题.考虑到由于\(K \le 10\),所以我们用两个大vector--\(Left,Right\),\(L ...
- [CERC2017]Intrinsic Interval——扫描线+转化思想+线段树
[CERC2017]Intrinsic Interval https://www.luogu.org/blog/ywycasm/solution-p4747# 这种“好的区间”,见得还是比较多的了. ...
- 在eclipse中从gitlab上面下载项目
(1)在eclipse中 import --git--uri--输入用户名密码,下载,这个时候是在本地建立了一个本地仓库 (2)把仓库中的项目导入到eclipse的工作空间中. (3)将所需要的项目转 ...
- 用静态工厂的方法实例化bean
//代码如下: package com.timo.domain; public class ClientService { //use static factory method create bea ...
- bzoj 5099 [POI2018]Pionek 计算几何 极角排序
[POI2018]Pionek Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 269 Solved: 80[Submit][Status][Disc ...
- 使用mysqldump命令备份恢复MySQL数据库
1.各种用法说明 A. 最简单的用法: mysqldump -uroot -pPassword [database name] > [dump file] 上述命令将指定数据库备份到某dump文 ...
- 【转载】深入理解PHP Opcode缓存原理
转载地址:深入理解PHP Opcode缓存原理 什么是opcode缓存? 当解释器完成对脚本代码的分析后,便将它们生成可以直接运行的中间代码,也称为操作码(Operate Code,opcode).O ...
- vue与node模版引擎的渲染标记{{}}(双花括号)冲突
由于之前练习koa2,直接渲染的jquery写的传统页面. 这次想偷懒,直接script引入vue,发现渲染不出data值. 渲染引擎用得是xtpl, 找了半天没有发现可以修改xtpl渲染分隔符的配置 ...