Skip to main content

Merge, Rebase

merge vs rebase

https://www.atlassian.com/git/tutorials/merging-vs-rebasing

Make the current Git branch a master branch

git checkout better_branch
git merge --strategy=ours master    # keep the content of this branch, but record a merge
git checkout master
git merge better_branch             # fast-forward master up to the merge

rename branch (local and remote)

  • git branch -m master main - rename master to main
  • git push -u origin main - push branch with new name
  • set remote default branch in remote repo.
  • protect new brunch, unprotect old branch (in remote repo)
  • git push origin --delete master - delete branch in remote repo