git生成patch以及am patch

1、生成某次commit之后的patch

miyuehu@s6:~/repo/m$ git format-patch c92ec02610efac65d2bf979127541400416d1610
0001-add-build.sh.patch
0002-v1.4-released.patch


2、生成某次commit的patch

miyuehu@s6:~/repo/m$ git format-patch -1 c92ec02610efac65d2bf979127541400416d1610
0001-v1.4.patch


3、am patch出错后的处理

miyuehu@s6:~/repo/tmp$ git am < 0001-fix-bug-with.patch
Applying: fix bug with
/home/miyuehu/repo/tmp/.git/rebase-apply/patch:220: trailing whitespace.

/home/miyuehu/repo/tmp/.git/rebase-apply/patch:245: trailing whitespace.

error: patch failed: android/device/*.java:307
error: android/device/*.java: patch does not apply
error: patch failed: android/device/**.java:27
error: android/device/**.java: patch does not apply
error: patch failed: android/device/***.java:30
error: android/device/***.java: patch does not apply
Patch failed at 0001 fix bug with
The copy of the patch that failed is found in:
   /home/miyuehu/repo/tmp/.git/rebase-apply/patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

此时,无需执行git am --continue/git am --skip/git am --abort

执行

miyuehu@s6:~/repo/tmp$ git apply --reject 0001-fix-bug-with.patch
0001-fix-bug-with.patch:21: trailing whitespace.
                                                Log.i(TAG, "post onFailure");
0001-fix-bug-with.patch:28: trailing whitespace.
                                                Log.i(TAG, "post onFinish");
0001-fix-bug-with.patch:35: trailing whitespace.
                                                Log.i(TAG, "post onStart");
0001-fix-bug-with.patch:42: trailing whitespace.
                                                Log.i(TAG, "post onSuccess");
0001-fix-bug-with.patch:55: trailing whitespace.
        FileInfo mFileInfo;
Checking patch android/device/*.java...
Checking patch android/device/**.java...
Checking patch android/device/***.java...
Applied patch android/device/*.java cleanly.
Applied patch android/device/**.java cleanly.
Applied patch android/device/***.java cleanly.
warning: squelched 24 whitespace errors
warning: 29 lines add whitespace errors.

执行

miyuehu@s6:~/repo/tmp$ git status
On branch v1.4
Your branch is up-to-date with 'origin/v1.4'.

You are in the middle of an am session.
  (fix conflicts and then run "git am --continue")
  (use "git am --skip" to skip this patch)
  (use "git am --abort" to restore the original branch)

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   android/device/*.java
        modified:   android/device/**.java
        modified:   android/device/***.java
       
modified:   "doc/100\345\215\207\347\272\247\346\226\207\346\241\243.doc"

PS:這里应该显示中文的,需要配置git

miyuehu@s6:~$ git config --global core.quotepath false
miyuehu@s6:~$ vim .gitconfig

[user]
        name = miyuehu
        email = miyuehu@qq.com
[core]
        quotepath = false

這里git就能显示中文了。

 miyuehu@s6:~/repo/tmp$ git status -uno
On branch v1.4
Your branch is ahead of 'origin/v1.4' by 7 commits.
  (use "git push" to publish your local commits)

You are in the middle of an am session.
  (fix conflicts and then run "git am --continue")
  (use "git am --skip" to skip this patch)
  (use "git am --abort" to restore the original branch)

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   android/device/*.java
        modified:   android/device/**.java
        modified:   android/device/***.java
        modified:   doc/100升级文档.doc

执行

miyuehu@s6:~/repo/tmp$ git add android/device/*

fix conflicts and then run "git am --continue"

miyuehu@s6:~/repo/tmp$ git am --continue



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值