Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save DharmendraRathor/df22b03b16b8a16d8555a6f60983808f to your computer and use it in GitHub Desktop.
Save DharmendraRathor/df22b03b16b8a16d8555a6f60983808f to your computer and use it in GitHub Desktop.
Replace branch with master branch in git
You have branch having latest changes “latestBranch” and if you want to override master with latestBranch changes.
Use following commands
1. Checkout latestBranch.
git checkout latestBranch
2. Merge latestBranch with master with strategy as ours. Current branch changes will be used in case of conflicts.
git merge -s ours master
3. Checkout master branch.
git checkout master
4. Merge master with latestBranch
git merge latestBranch
5. Push master with latest code.
git push (git push origin master)
you can also use git force push “git push -f origin master”. Please check branch history before running git push
@DharmendraRathor
Copy link
Author

Documentation for git ours strategy : https://git-scm.com/docs/git-merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment