首页 技术 正文
技术 2022年11月15日
0 收藏 436 点赞 4,454 浏览 1346 个字

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

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

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

  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. If you often merge with the same branch, you may want to
  8. use something like the following in your configuration file:
  9. [branch “debug”]
  10. remote = <nickname>
  11. merge = <remote-ref>
  12. [remote “<nickname>”]
  13. url = <url>
  14. fetch = <refspec>
  15. See git-config(1) for details.

问题解析:

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

解决方法:

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

  1. git branch –set-upstream debug origin/debug

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

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

  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. [branch “debug”]
  13. remote = origin
  14. merge = refs/heads/debug
  15. [receive]
  16. denyCurrentBranch = ignore

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

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,492
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,907
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,740
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,495
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,132
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,297