Skip to content

git攻略 #79

Open
Open
@v5tech

Description

@v5tech

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions