Git commands that could break/rewrite the history

前端 未结 4 1422
终归单人心
终归单人心 2020-11-22 05:51

Can you provide a list of (all, or the most common) the operations or commands that can compromise the history in git?

What should be absolutely avoided?

    <
4条回答
  •  失恋的感觉
    2020-11-22 06:22

    Off the top of my head:

    • git commit --amend will re-write the previous commit
    • git rebase can rewrite multiple commits (rebase is also called when using git pull with the --rebase flag or the branch.$name.rebase config option)
    • git filter-branch can rewrite multiple commits
    • git push -f can change the commit a branch points to (same goes for the git push origin +branch syntax)
    • git reset can change the commit a branch points to
    • git branch -f can change the commit a branch points to (by recreating a branch with the same name)
    • git checkout -B can change the commit a branch points to (by recreating a branch with the same name)

提交回复
热议问题