git rebase

Creator
Creator
Seonglae ChoSeonglae Cho
Created
Created
2020 Jan 9 14:31
Editor
Edited
Edited
2026 Feb 18 17:8

Enabled by AI agents as an alternative to merge

Conceptually similar to running cherry-pick multiple times
History becomes cleaner, but commits are lost and it's tedious to do per commit
Since this modifies history, avoid rebasing on master and instead rebase main before merging to master
In other words, enables fast-forward merge for features

VSCode interactive setup

Modifying multiple commit messages

  • amend e - edit commit
  • drop d - delete commit
  • squash s - combine commits
  • pick p - use commit
  • reword r - use and edit
  • fixup f - discard log and s
  • exec x - exec run command

Moving base branch

  • Moves the branch divergence point to the latest commit of the target branch, rebasing current commits there

Updating to current time

If you've done git rebase -i, you should always follow it with git rebase --continue.
Rewind time, then fast-forward again

Canceling rebase

Merge conflict flow

 
 
Git Interactive Rebase, Squash, Amend and Other Ways of Rewriting History
"Please rebase on top of master and we'll merge your pull request". "Can you please squash your commits together so we get a clean, reversible git history?". "Can you rewrite your commit's message to describe better the problem it solves, and how it solves it?". Questions like these are commonly asked in pull requests.
Git Interactive Rebase, Squash, Amend and Other Ways of Rewriting History
Git Rebase & Squash in VS Code using GitLens Supercharge
https://aka.ms/vscode-git | Use Visual Studio Code for Rebase & Squash with GitLens Supercharge.
Git Rebase & Squash in VS Code using GitLens Supercharge
git rebase로 commit 합치기
Git을 사용하다보면 commit을 한 후에 누락된 작업이 생각이 나거나 이미 커밋한 내용 중에 수정이 필요한 경우가 종종 생기는데, 추가로 작업한 후에 다시 commit을 하면 동일한 이름의 commit 혹은 의미없는 새로운 commit이 생기게 된다. 이때, git rebase 명령을 이용하면 변경사항은 적용하면서 이전과 현재의 커밋을 합칠 수 있다.
git rebase로 commit 합치기
Take advantage of Git rebase
These days, developers spend a lot of time reviewing merge requests and taking these reviews into account to improve the code. We'll discuss how Git rebase can help in speeding up these review cycles. But first, let's take a look at some workflow considerations.
Take advantage of Git rebase
 
 
 

Recommendations