git rebase 修改最近作者注释
2017-08-24 15:05
507 查看
https://gist.github.com/trey/9588090
Change the email address for a git commit.
$ git commit --amend --author="Author Name <email@address.com>"
or
$ git commit --amend --reset-author
If you need to change the author for a commit older than the most recent, do a
git rebase -i. For example, if
you wanted to change the penultimate commit, you'd run:
$ git rebase -i HEAD~2
Then choose
eor
editnext
to the appopriate commit, then when it asks you to amend, run the same command as you would for the most recent commit:
$ git commit --amend --reset-author
Then, to finish, you'd run:
$ git rebase --continue
And you're done. Don't forget you'll have to
--forcepush if you've already pushed those commits to your remote.
source
http://blog.csdn.net/hudashi/article/details/7664631/
原文:
http://gitbook.liuhui998.com/4_2.html
一、基本
git rebase用于把一个分支的修改合并到当前分支。
假设你现在基于远程分支"origin",创建一个叫"mywork"的分支。
$ git checkout -b mywork origin
假设远程分支"origin"已经有了2个提交,如图
现在我们在这个分支做一些修改,然后生成两个提交(commit).
$ vi file.txt
$ git commit
$ vi otherfile.txt
$ git commit
...
但是与此同时,有些人也在"origin"分支上做了一些修改并且做了提交了. 这就意味着"origin"和"mywork"这两个分支各自"前进"了,它们之间"分叉"了。
在这里,你可以用"pull"命令把"origin"分支上的修改拉下来并且和你的修改合并; 结果看起来就像一个新的"合并的提交"(merge commit):
但是,如果你想让"mywork"分支历史看起来像没有经过任何合并一样,你也许可以用 git rebase:
$ git checkout mywork
$ git rebase origin
这些命令会把你的"mywork"分支里的每个提交(commit)取消掉,并且把它们临时 保存为补丁(patch)(这些补丁放到".git/rebase"目录中),然后把"mywork"分支更新 为最新的"origin"分支,最后把保存的这些补丁应用到"mywork"分支上。
当'mywork'分支更新之后,它会指向这些新创建的提交(commit),而那些老的提交会被丢弃。 如果运行垃圾收集命令(pruning garbage collection), 这些被丢弃的提交就会删除. (请查看 git gc)
二、解决冲突
在rebase的过程中,也许会出现冲突(conflict).
在这种情况,Git会停止rebase并会让你去解决 冲突;在解决完冲突后,用"git-add"命令去更新这些内容的索引(index), 然后,你无需执行 git-commit,只要执行:
$ git rebase --continue
这样git会继续应用(apply)余下的补丁。
在任何时候,你可以用--abort参数来终止rebase的行动,并且"mywork" 分支会回到rebase开始前的状态。
$ git rebase --abort
三、git rebase和git
merge的区别
现在我们可以看一下用合并(merge)和用rebase所产生的历史的区别:
当我们使用Git log来参看commit时,其commit的顺序也有所不同。
假设C3提交于9:00AM,C5提交于10:00AM,C4提交于11:00AM,C6提交于12:00AM,
对于使用git merge来合并所看到的commit的顺序(从新到旧)是:C7
,C6,C4,C5,C3,C2,C1
对于使用git rebase来合并所看到的commit的顺序(从新到旧)是:C7
,C6‘,C5',C4,C3,C2,C1
因为C6'提交只是C6提交的克隆,C5'提交只是C5提交的克隆,
从用户的角度看使用git rebase来合并后所看到的commit的顺序(从新到旧)是:C7
,C6,C5,C4,C3,C2,C1
另外,我们在使用git pull命令的时候,可以使用--rebase参数,即git pull --rebase,这里表示把你的本地当前分支里的每个提交(commit)取消掉,并且把它们临时
保存为补丁(patch)(这些补丁放到".git/rebase"目录中),然后把本地当前分支更新
为最新的"origin"分支,最后把保存的这些补丁应用到本地当前分支上。关于git
pull的更多内容请参考《git
pull简介》
相关文章推荐
- git 修改作者名称
- git commit 如何修改上一个commit以及合并最近两个commit
- git pull --rebase丢文件丢失修改了怎么办
- Git - 如何修改开源项目并推送给作者 / 克隆远程仓库到本地
- 在Eclipse中修改自动生成的注释里的作者信息
- git rebase -i 修改历史提交
- git 修改注释
- 更改eclipse(myeclipse) author的默认名字 --- 修改MyEclipse eclipse 注释的作者
- git修改已提交记录的注释
- Xcode-5.1.1修改文件注释作者
- MyEclipse修改注释的作者
- 设置eclipse中的编辑区的背景颜色、注释文字的颜色、修改注释内作者名和时间
- Git 修改本地和远程的commit的作者信息
- 修改配置myeclipse/eclipse的注释作者名author
- git rebase & merge 将其他分支的修改合并到当前分支
- Android Studio 怎么修改默认注释create by 作者名
- 【小技巧】修改eclipse中Java注释中的作者日期等信息
- mybatis generator逆向工程自动生成带中文注释修改版(添加了实体类注释)文末附有git下载地址
- eclipse(修改注释作者名称)
- 更改eclipse(myeclipse) author的默认名字 --- 修改MyEclipse eclipse 注释的作者