Chinaunix首页 | 论坛 | 博客
  • 博客访问: 495936
  • 博文数量: 59
  • 博客积分: 2968
  • 博客等级: 少校
  • 技术积分: 648
  • 用 户 组: 普通用户
  • 注册时间: 2009-04-23 22:20
个人简介

IT圈泥瓦匠一枚,混迹过国产处理器圈,从事Linux BSP开发混一软件经理职务,现漂浮在云端从事OpenStack-Nova相关设计工作。

文章分类

全部博文(59)

文章存档

2014年(1)

2013年(2)

2012年(7)

2011年(26)

2010年(9)

2009年(14)

我的朋友

分类: LINUX

2012-11-08 14:53:50

1. git am 失败的处理方法

点击(此处)折叠或打开

  1. # git am PATCH
  2. Applying: Modify the configuration file.
  3. error: patch failed: arch/mips/configs/loongson3_defconfig:60
  4. error: arch/mips/configs/loongson3_defconfig: patch does not apply
  5. Patch failed at 0001 Modify the configuration file.
  6. When you have resolved this problem run "git am --resolved".
  7. If you would prefer to skip this patch, instead run "git am --skip".
  8. To restore the original branch and stop patching run "git am --abort".
如上所属,如果冲突发生,git只是输出上述信息,然后就停下来。一个小冲突会导致整个patch都不会被集成。
    处理这种问题的最简单方法是先使用 git am --abort,然后手动的添加此patch, patch -p1 < PATCH,手动解决掉代码冲突,最后使用 git add . 和 git commit -a 提交代码。但是这样做有个问题就是你会失去PATCH中原本包含的commit信息(比如From,Date,Subject,Signed-off-by等)。
    应该有一种更聪明的方法。在 .git/rebase-apply 目录下,存放着相应的补丁文件,名字是“0001” (在更新的git版本中,存放补丁文件的目录名有所改变,这里使用的git版本是 1.7.4.1)。事实上,你可以使用 git apply 命令打patch(git apply 是git中的patch命令)。如同使用 patch -p1 命令时一样,然后手动解决代码冲突(检视生成的 .rej 文件,与冲突文件比较,修改冲突内容,并最终把文件加入到index中):
具体步骤如下:

点击(此处)折叠或打开

  1. $ git apply PATCH --reject
  2. $ edit edit edit
  3. (译注:根据.rej文件手动解决所有冲突)
  4. $ git add FIXED_FILES
  5. $ git am --resolved
想多一些解释,好吧。git am 并不改变index,你需要使用 git apply --reject 打patch(保存在 .git/rebase-apply),手动解决代码冲突,(译注:使用 git status 列出所有涉及文件),把所有文件(不仅仅是引起冲突的文件)添加到(git add)index,最后告诉 git am 你已经解决(--resolved)了问题。这样做的好处是你不需要重新编辑commit信息。而且,如果你正在打的是一系列patch(就是说你在打的是多个patch,比如 git am *.patch)你不需要使用 git am --abort,然后又 git am。

2. 清除untrack files文件
   使用 git clean 命令进行清除。
   git-clean -df  清除未跟踪文件和目录
   git-clean -dn  列出那些文件将被清除。
阅读(4381) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~