Skip to content

Instantly share code, notes, and snippets.

@sephraim
Created February 19, 2025 09:56
Show Gist options
  • Save sephraim/75006b2c43c0e6bc19d226678c5b04b4 to your computer and use it in GitHub Desktop.
Save sephraim/75006b2c43c0e6bc19d226678c5b04b4 to your computer and use it in GitHub Desktop.
[Sync master (main) / develop branches in git]
# NOTE: THE FOLLOWING IS FOR *NON-FORKED* REPOS ONLY.
# "origin" WILL REFER TO THE *MAIN* REPO, NOT A FORK.
# AND THERE IS NO "upstream".
# Prep...
git fetch origin
# DEVELOP
git checkout develop
git pull --rebase origin develop # (1.) pull in latest changes from remote "develop"
git merge origin/master # (2.) merge in latest changes from remote "master" (ideally this is nothing, unless there were hotfixes on master recently)
git push origin develop # (3.) push changes to remote "develop"
# MASTER
git checkout master
git pull --rebase origin master # (1.) pull in latest changes from remote "master"
git merge develop # (2.) pull in latest changes from "develop" (note that by now this will include all changes from remote "develop" AND remote "master" due to running above steps)
git push origin master # (3.) push changes to remote "master"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment