Open
Description
http://jlord.us/git-it/index.html
1.修改第一次提交
git rebase -i --root
git commit --amend
git rebase --continue
注:
1)git rebase -i
默认会打开nano
编辑器,将要修改的commit id
标记为edit
,然后按下键盘CTRL+O
保存、CTRL+X
退出。
2)git commit --amend
修改提交
2.修改最近一次提交
git commit -a --amend -m "commit msg"
3.修改第N次提交
git rebase -i HEAD~N
git commit --amend
git rebase --continue
4.从所有提交中删除一个文件
git filter-branch --tree-filter 'rm -f passwords.txt' HEAD
5.全局性地更换电子邮件地址
git filter-branch --commit-filter '
if [ "$GIT_AUTHOR_EMAIL" = "root@ruby" ];
then
GIT_AUTHOR_NAME="sxyx2008";
GIT_AUTHOR_EMAIL="sxyx2008@163.com";
git commit-tree "$@";
else
git commit-tree "$@";
fi' HEAD
或者
git filter-branch -f --env-filter "GIT_AUTHOR_NAME='冯靖'; GIT_AUTHOR_EMAIL='sxyx2008@163.com'; GIT_COMMITTER_NAME='ameizi'; GIT_COMMITTER_EMAIL='sxyx2008@163.com';"
git push -u -f