DEV Community

Cover image for Merge changes made in the "master" branch into your development branch.
raielly
raielly

Posted on • Edited on

Merge changes made in the "master" branch into your development branch.

If we needs to stay in sync with the latest changes made in "master", while also retaining a complete record of all changes made. Let's try to use rebasing.

git checkout master
git pull --rebase
git checkout branch_name
git rebase master
git push -f origin branch_name
Enter fullscreen mode Exit fullscreen mode

Note: Don't forget to backup first your branch when doing changes

git branch branch_name-bkp
Enter fullscreen mode Exit fullscreen mode

If there's any conflict arise, use this command as needed to fix the issue based on the situation and the hints provided by git.

git rebase --continue
git rebase --skip
git mergetool
Enter fullscreen mode Exit fullscreen mode

Please continue this process until all conflicts are resolved.

At this point, our branch should be rebased and aligned with the "master" branch, and the remote should also be updated. When checking the Git log, there should be no instances of "behind" or "ahead".

Top comments (2)

Collapse
 
kenneth_sagarino_45baa0b9 profile image
Kenneth Sagarino

I never understand git until I read your blog. You're an angel sent from above

Collapse
 
raielly profile image
raielly

Thanks man! Cheers! 😎