Rename master branch for both local and remote Git repositories -


i have branch master tracks remote branch origin/master.

i want rename them master-old both locally , on remote. possible? other users tracked origin/master (and updated local master branch via git pull), happen after renamed remote branch? git pull still work or throw error couldn't find origin/master anymore?

then, further on, want create new master branch (both locally , remote). again, after did this, happen if other users git pull?

i guess result in lot of trouble. there clean way want? or should leave master , create new branch master-new , work there further on?

the closest thing renaming deleting , re-creating on remote. example:

git branch -m master master-old git push remote :master         # delete master git push remote master-old      # create master-old on remote  git checkout -b master some-ref # create new local master git push remote master          # create master on remote 

however has lot of caveats. first, no existing checkouts know rename - git not attempt track branch renames. if new master doesn't exist yet, git pull error out. if new master has been created. pull attempt merge master , master-old. it's bad idea unless have cooperation of has checked out repository previously.

note: newer versions of git not allow delete master branch remotely default. can override setting receive.denydeletecurrent configuration value warn or ignore on remote repository. otherwise, if you're ready create new master right away, skip git push remote :master step, , pass --force git push remote master step. note if you're not able change remote's configuration, won't able delete master branch!

this caveat applies current branch (usually master branch); other branch can deleted , recreated above.


Comments

Popular posts from this blog

unicode - Are email addresses allowed to contain non-alphanumeric characters? -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c++ - Convert big endian to little endian when reading from a binary file -