[置顶] 使用git遇到的问题汇总
2016-07-19 17:52
363 查看
1、git中remotes/origin/HEAD指向的分支丢失
用git命令查看分支时,会提示一个错误信息:
查看几个分支都正在使用,用branch -a查看到remotes/origin/HEAD指向了一个不存在的分支:
origin/demo这个分支以前有用过,后来删除掉了,不知道为什么remotes/origin/HEAD会指向这个分支,一般都是指向master分支。
知道问题后,打开 .git/refs/remotes/origin/HEAD 修改demo为master保存。
这时候再用branch -av就不会报最开始的错误了。
2、Git新建本地分支与远程分支关联问题:git branch –set-upstream-to
git在本地新建分支, push到remote服务器上之后,再次pull下来的时候,如果不做处理会报以下提示:
实例如下,其中test为创建的分支
命令的最终修改都是针对config文件。
使用–set-upstream-to去跟踪远程分支。
注意仓库.git目录下的config文件
后续会添加更多问题。。。
微信:
用git命令查看分支时,会提示一个错误信息:
$ git branch -av ...... ...... error: some refs could not be read
查看几个分支都正在使用,用branch -a查看到remotes/origin/HEAD指向了一个不存在的分支:
$ git branch -a ...... remotes/origin/HEAD -> origin/demo ......
origin/demo这个分支以前有用过,后来删除掉了,不知道为什么remotes/origin/HEAD会指向这个分支,一般都是指向master分支。
知道问题后,打开 .git/refs/remotes/origin/HEAD 修改demo为master保存。
$ vim .git/refs/remotes/origin/HEAD ref: refs/remotes/origin/master
这时候再用branch -av就不会报最开始的错误了。
2、Git新建本地分支与远程分支关联问题:git branch –set-upstream-to
git在本地新建分支, push到remote服务器上之后,再次pull下来的时候,如果不做处理会报以下提示:
There is no tracking information for the current branch. Please specify which branch you want to merge with. See git-pull(1) for details. git pull <remote> <branch> If you wish to set tracking information for this branch you can do so with: git branch --set-upstream-to=origin/<branch> dev
问题解析:
git本地新建一个分支后,必须要做远程分支关联。如果没有关联,git会在下面的操作中提示你显示的添加关联。关联目的是如果在本地分支下操作: git pull, git push ,不需要指定在命令行指定远程的分支.推送到远程分支后,你只要没有显示指定,git pull的时候,就会提示你。解决方法:
使用命令git branch --set-upstream-to ;
实例如下,其中test为创建的分支
view plaincopy to clipboardprint? git branch --set-upstream-to test origin/test
命令的最终修改都是针对config文件。
使用–set-upstream-to去跟踪远程分支。
view plaincopy to clipboardprint? [core] repositoryformatversion = 0 filemode = true bare = true logallrefupdates = true[remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* url = git@192.168.1.145:android4.4.2_r1.git[branch "master"] remote = origin merge = refs/heads/master[branch "test"] remote = origin merge = refs/heads/test[receive]denyCurrentBranch = ignore
注意仓库.git目录下的config文件
后续会添加更多问题。。。
打赏信息:
支付宝微信:
相关文章推荐
- 新浪微博分享时的错误总结
- linux php安装memcache扩展
- LeetCode之克隆图
- 安卓自定义上面圆角下面直角的RoundCornerImageView
- Swift build(.build)和ring(.gz)的数据结构和文件的持久化机制
- 数据库分库分表(sharding)系列(五) 一种支持自由规划无须数据迁移和修改路由代码的Sharding扩容方案
- 【LruCache完全解析】Android高效加载大图、多图解决方案,有效避免程序OOM (AdapterView使用LruCache图片缓存)
- Gson 的使用
- vb中是的文本框输入数字自动以千为分隔加逗号
- SpringMVC学习笔记
- mysql悲观锁总结和实践
- ThreadPoolExecutor源码解析(基于Java1.8)
- Makefile (二) 介绍
- ios ZXing 二维码、条形码扫描
- 一周极客热文:C\C++代码优化的27个建议
- linux下 open() write() read() close函数
- 你真的理解AIDL中的in,out,inout么?
- Rxjava+数据库?来用用SqlBrite和SqlDelight吧!
- UIControl的子类UISwitch, UISegmentedCntrol, UIPageControl详解
- 网站的PV UV IP---网站常见软件性能