![]() If you hadnt pushed the branch to remote, this would have been the solution: git branch -m assortment However, since the branch has been pushed to remote, we need to do a few extra steps. You get a request to rename the branch to assortment. These need to be reconfigured for the new branch. Your local branch feature is now pushed to remote branch. For example, Travis CI scheduled/cron builds are set up by branch. Some CI services have settings that will need to be updated for the new branch. After renaming your default branch to main, search your repository for any mentions of master. Rather than go through all the possibilities, here is a checklist of places to look. Since master has been considered a well-known term, itâs likely weâve hardcoded it in CI configuration, build-badge URLs, and automation code. Updating Git and GitHub is just part of the fix. Now weâll see that three references point to the latest main commit: * 0f9cde7 - (HEAD -> main, origin/main, origin/HEAD) Merge pull request #126. To fix this, we can ask Git to set the remote HEAD (i.e., origin/HEAD) automatically, which will be the latest commit on the default branch: % git remote set-head origin -auto ![]() If we attempt to use the symbolic-ref now (e.g., git pull origin is an implicit use of this symbolic-ref), we would get an error. Optional command (if you are not on the target branch) git checkout git branch -m .Next, you just have to specify the name of the new branch. The trouble is that origin/HEAD is not pointing there and doesnât exist since we just deleted the commit and branch where it pointed. In order to change a branch name on Git, you have to use the git branch command followed by the -m option. * 0f9cde7 - (HEAD -> main, origin/main) Merge pull request #126. If you look at the Git log now, youâll see that two references point to the latest main commit: the local HEAD and the remote branch main. % git push origin -delete master To - master Step 8. Under the Default branch heading, select the main branch and choose Update.Īlternatively, you can push a remote branch delete request from the command line. % git push -u origin main Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 remote: remote: Create a pull request for 'main' on GitHub by visiting: remote: remote: To * main -> main Branch 'main' set up to track remote branch 'main' from 'origin'. Now, weâre going to send our renamed branch off to the interwebs. nothing to commit, working tree clean Step 4. % git branch -m master main % git status On branch main Your branch is up to date with 'origin/master'. Notice that remotely, our local main branch is still tracking the remote master. In this step, we are simply changing, locally, the name of master to main. % git fetch -all -p Fetching origin % git pull Already up to date. Weâll go to the directory of the repositoryâs local clone and update the local and remote default branches: % cd scratchrelaxtv % git checkout master Already on 'master' Your branch is up to date with 'origin/master'. We need to make sure that our local branch is in sync with whatâs out on GitHub. The default branch is shown prominently on the main page so we know that the repositoryâs default branch is master.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |