![]() The other commands are all concerned about matching local branches to remote ones (via tracking branches) and updating the HEAD reference to point to the "default" branch. It's just git branch -m master main to rename a branch. That's it! Note that it gets much simpler if you have no remote/upstream. Switch your local branch to track the new remote branch. The following steps will get you back on track:įetch the latest branches from the remote. If you know the branch was renamed, there's nothing to fear. Now what do you have to do if it's someone else's repo which renamed a branch, and you're left holding a "dangling" reference (so to speak) to a remote branch that no longer exists? That's covers it on your end and where your repository is hosted. Log into the upstream repository host (GitHub, GitLab, Bitbucket, etc.) and change the "default branch". ![]() Push renamed branch upstream and set remote tracking branch. I thought I would post a write-up here about it, in case anyone is interested or needs to learn it themselves: Therefore, I spent some time today coming up with a procedure for renaming branches, which I then used to rename around 60 public and private Git repositories that I maintain. ![]() It's up to the developer to go to where it's hosted (GitHub, GitLab, Bitbucket, etc.) to change it. It gets even trickier for the default branch, because of an interesting fact about Git that I consider to be a design flaw: Git has no built-in method of changing the default branch remotely. However, it gets a tad harder when you want to rename it both locally and upstream. ![]() Renaming Git branches isn't that difficult. However, I hope we can all agree that it's always good to have the know-how and the tools to be able to change the names we use. Recently, the CEO of GitHub responded to a Tweet about renaming default Git branches from master to main, saying, "It's a great idea and we are already working on this!" Now, you may or may not believe that terms such as master, slave, and blacklist are racially-charged or have undesirable connotations nowadays. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |