zoukankan      html  css  js  c++  java
  • *****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 <远程主机名> <远程分支名>:<本地分支名>
  • 相关阅读:
    Tomcat6 一些调优设置内存和连接数
    【原创】使用c3p0数据库连接池时出现com.mchange.v2.resourcepool.TimeoutException
    JVM内存的设置
    JBOSS以及tomcat最大连接数配置和jvm内存配置
    摘抄python __init__
    Python中__init__方法介绍
    Python 绝对简明手册
    python中eval, exec, execfile,和compile [转载]
    extern、static、auto、register 定义变量的不同用法
    Python 网络编程说明
  • 原文地址:https://www.cnblogs.com/kenshinobiy/p/4548465.html
Copyright © 2011-2022 走看看