Rebase
To rebase your current branch with the develop branch, follow these steps:
Basic Rebase Process
-
Fetch all the latest changes from the remote:
git fetch -
Make sure you're on your feature branch:
git checkout your-branch-name -
Rebase your branch on top of the develop branch:
git rebase origin/developIf you encounter merge conflicts during the rebase:
-
Resolve conflicts in your editor, then:
git add . -
Continue the rebase process:
git rebase --continue -
If you need to abort the rebase:
git rebase --abort
-
Alternative with Stashing (if you have uncommitted changes)
-
Stash your changes:
git stash -
Rebase with develop:
git checkout your-branch-name git rebase origin/develop -
Apply your stashed changes:
git stash pop
Force Push After Rebase
After rebasing, you'll need to force push your changes since you've rewritten history:
git push --force-with-lease origin your-branch-name
The --force-with-lease option is safer than --force as it prevents you from overwritting others' work.