简体   繁体   中英

Git make remote master point to another branch

We got a 'dev' branch thats been functioning as de-facto master for quite a while.

Is there a way to make my remote/master just point to the same place as remote/dev ? (no merging / rebasing / extra work).

(More or less a rename of dev to master)

Thanks in advance

Checkout master branch, reset it to dev, push. This will affect users downstream who may have branches off your remote/master.

git checkout master

git reset --hard remote/dev

git push -f

This will cause you to lose any commits you have made since your remote and dev diverged, but you will end up with the same state as remote/dev.

Assuming your remote is named origin ,

git push origin +origin/dev:refs/heads/master

Then, if you want also to delete dev :

git push origin :refs/heads/dev

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM