Skip to content

Git rebase

What is rebase?

  • rebase is repeated cherry-picking

How to use rebase?

Merge methods | GitLab Docs

  • pull with rebase, the default behavior is merge
git pull --rebase
  • don't open a merge commit when

Rebase snippets

从最初的 commit 开始变基

git rebase -i --root
  • edit 修改此 commit
  • squash 与上一 commit 合并,保留 commit message

显示 commit 的信息

git show --pretty=fuller COMMIT_HASH

修改 commit 日期而不修改内容

GIT_COMMITTER_DATE="Wed Sep 23 10:00 2015 +0100" git commit --amend --no-edit --date "Wed Sep 23 10:00 2015 +0100"

继续变基的下一操作

git rebase --continue