Errors may occur:
Updates were rejected because the tip of your current branch is behind
its remote counterpart. If you want to integrate the remote changes ,
use 'git pull' before pushing again.
1. Pull Remote Changes
Pull the latest changes from the remote branch and merge them into your local branch via command:
git pull origin main –rebase
–rebase ensures your local changes are applied along with the latest remote changes, keeping commit history cleaner
2. Resolve Conflicts (if any)
3. Push the Changes
git add .
git rebase --continue
git push -u origin main
Why --rebase
?
rebase
avoids unnecessary merge commits and keeps the commit history cleaner.
If you prefer to merge instead, you can use:
git pull origin main