git 整理历史技巧
git reset --soft HEAD~3 && git commit --edit -m"$(git log --format=%B --reverse HEAD..HEAD@{1})"
中间两个点,不是三个点
HEAD..HEAD@{1}
合并最近三次的历史
提交到远程
git push origin --force
If you want to start editing the new commit message with a concatenation of the existing commit messages (i.e. similar to what a pick/squash/squash/…/squash git rebase -i instruction list would start you with), then you need to extract those messages and pass them to git commit:
Squash my last X commits together using Git
删除 untracked files
git clean -f
连 untracked 的目录也一起删掉
git clean -fd
修改最近的一条提交记录
( 尚未提交到,远程仓库 )
修改后,最近的 commit id , 会变掉
git commit --amend
Rewriting the most recent commit message
You can change the most recent commit message using the git commit --amend command.
In Git, the text of the commit message is part of the commit. Changing the commit message will change the commit ID
–i.e., the SHA1 checksum that names the commit. Effectively, you are creating a new commit that replaces the old one.