Skip to content

Instantly share code, notes, and snippets.

@Salaander
Salaander / gist:853471aacc4921f72e0db47b03913cea
Last active October 15, 2019 08:18
master-to-origin alias to move local master to origin/master and keep local diff
# If you pulled the latest changes and you have commits
# on the master branch that diverge from remote but you do not
# need them and just want to move the master branch locally to origin/master
alias master-to-origin='git co master && git branch master_moved_`date +%m-%d-%Y` && git co origin/master && git branch -D master && git branch master && git branch --set-upstream-to=origin/master master && git checkout master'
# Breakdown
git co master
git branch master_moved_`date +%m-%d-%Y`
git co origin/master