1. 给某个文件打patch
$: git apply 0001-modify-fb.patch
0001-modify-fb.patch:28: trailing whitespace.
warning: 1 line adds whitespace errors. ###已经打上patch
注:这个命令跟patch 命令效果基本上是一样的,不会生成commit信息,相比git am --signoff < yourpatch 这个命令生产的
带commit,我比较喜欢用前者。
2. git 生成 patch
$ git add drivers/video/msm/mdss/mdss_fb.c ....(将你所要打patch的文件都加进index)
$ git commit -m"modify the mdss"
$ git format-patch -1 commit_id
OK ,一个patch就生成了。
注意:
如果不想这次就提交,可以撤销删除这个commit,
根据–soft –mixed –hard,会对working tree和index和HEAD进行重置:
git reset –mixed:此为默认方式,不带任何参数的git reset,即时这种方式,它回退到某个版本,只保留源码,回退commit和index信息
git reset –soft:回退到某个版本,只回退了commit的信息,不会恢复到index
file一级。如果还要提交,直接commit即可
git reset –hard:彻底回退到某个版本,本地的源码也会变为上一个版本的内容
HEAD 最近一个提交
HEAD^ 上一次
<commit_id> 每次commit的SHA1值. 可以用git log 看到,也可以在页面上commit标签页里找到
亲测 git
reset –soft命令,只是撤销了commit的提交记录,commit改动的代码仍然存在,很受用。
git
reset --soft commit-id,其中的commit-id指的是撤销之前的那个commit id.