How to use Git Rebase
1. Switch to your main branch with
git checkout main
2. Update your local main branch with following command. This is so we have the latest HEAD of main available for the rebase.
git pull
3. Switch back to your branch new_branch and make commit
git checkout new_branch
touch abc1.txt
git add .
git commit -m "Added abc1.txt"
4. Use git rebase new_branch, this will complete the rebase, replaying your commits on top of the HEAD of main.
git checkout main
git rebase new_branch
How to Use Git Rebase?
Git rebase can integrate the changes from one branch to another by overcoming the problems that we might have faced while using the git merge command. The changes we will do will be recorded in the form of logs which are useful to go through if any mistakes happen.
Table of Content
- What is Git Rebase?
- Uses of Git Rebase
- Some common use cases for git rebase include
- Git Rebase Commands
- How to use Git Rebase