To update your current branch (fix/STORY-1343-hero-section
) from the main branch using rebase instead of merge, follow these steps:
# First, fetch the latest changes from remote
git fetch origin
# Then rebase your current branch on top of main
git rebase origin/main
# Then update your code to the repository:
git push --force-with-lease origin HEAD
If you encounter any conflicts during rebase:
- Resolve the conflicts manually
- Add the resolved files with
git add <file>
- Continue the rebase with
git rebase --continue
Using rebase instead of merge keeps your commit history linear and cleaner, making it appear as if you built your changes directly on top of the latest main branch.
The --force-with-lease flag is safer than just --force as it will fail if someone else has made changes to the remote branch that you haven't fetched yet.