# [[Rebasing in Git]] Rebasing in [[Git]] is a way to apply changes that someone else has made on another branch, but differs from merging in that it does so without combining the two branches. Merging takes changes from three sources: Branch 1, Branch 2, and the most recent common ancestor of the two branches. The end result is that there is only one branch and one most recent commit. ![](assets/1621807265_55.png) [^01] Rebasing takes changes from two sources: Branch 1 and Branch 2. It's like merging only the changes from someone else's branch, but stopping short of merging yours back into the main branch. ![](assets/1621807265_56.png) [^01] [^01]: https://git-scm.com/book/en/v2/Git-Branching-Rebasing ## Usage A common scenario for rebasing is when you have created a branch off the main branch and worked on code in your branch, but someone else has changed something in the main branch. ### Make sure the main branch is updated `git checkout master` `git pull` This will fetch any changes made to the main branch in your local copy. ### Rebase from your branch `git checkout experiment` `git rebase master` These commands might give you an error if you had already made changes on your branch. To save them but still rebase, consider [[Stashing in Git|stashing]] the changes, rebasing, and then applying the changes on top of the rebased branch.