zoukankan      html  css  js  c++  java
  • Git新建本地分支与远程分支关联问题:git branch --set-upstream【转】

    本文转载自:http://blog.csdn.net/netwalk/article/details/21088405

    Git新建本地分支与远程分支关联问题:git branch --set-upstream

    git在本地新建分支, push到remote服务器上之后,再次pull下来的时候,如果不做处理会报以下提示:

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

    问题解析:

    git本地新建一个分支后,必须要做远程分支关联。如果没有关联,git会在下面的操作中提示你显示的添加关联。关联目的是如果在本地分支下操作: git pull, git push ,不需要指定在命令行指定远程的分支.推送到远程分支后,你只要没有显示指定,git pull的时候,就会提示你。

    解决方法:

     使用命令git branch --set-upstream ;实例如下,其中debug为创建的分支

    [html] view plain copy
     
    1. git branch --set-upstream debug origin/debug  



    命令的最终修改都是针对config文件。

     

    使用--set-upstream去跟踪远程分支。 

     

    [html] view plain copy
     
    1. [core]  
    2.     repositoryformatversion = 0  
    3.     filemode = true  
    4.     bare = true  
    5.     logallrefupdates = true  
    6. [remote "origin"]  
    7.     fetch = +refs/heads/*:refs/remotes/origin/*  
    8.     url = git@192.168.1.160:android2.3.5_r1.git  
    9. [branch "master"]  
    10.     remote = origin  
    11.     merge = refs/heads/master  
    12.   
    13. [branch "debug"]  
    14.     remote = origin  
    15.     merge = refs/heads/debug  
    16.   
    17. [receive]  
    18. denyCurrentBranch = ignore  


    注意仓库.git目录下的config文件

     

  • 相关阅读:
    django学习笔记
    linux安装tree命令
    SecureCRT卡死的问题
    vim常用快捷键记录
    项目经理应具备的9种能力
    regsvr32命令
    通知栏构建和取消的基本认识
    AlertDialog 对话框 5种
    异步任务——AsyncTask的初步认识
    BaseAdapter的使用与优化
  • 原文地址:https://www.cnblogs.com/zzb-Dream-90Time/p/7256959.html
Copyright © 2011-2022 走看看