From 22e92084248285afe4bfbc0ee42956be41abdc76 Mon Sep 17 00:00:00 2001 From: Dexter Morganov Date: Sun, 14 Feb 2021 22:57:17 +0300 Subject: [PATCH] Update branch name highlight --- .../sections/branch-management.asc | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/book/03-git-branching/sections/branch-management.asc b/book/03-git-branching/sections/branch-management.asc index d70d4091d..5dcad611d 100644 --- a/book/03-git-branching/sections/branch-management.asc +++ b/book/03-git-branching/sections/branch-management.asc @@ -82,7 +82,7 @@ Do not rename branches that are still in use by other collaborators. Do not rename a branch like master/main/mainline without having read the section "Changing the master branch name". ==== -Suppose you have a branch that is called _bad-branch-name_ and you want to change it to _corrected-branch-name_, while keeping all history. +Suppose you have a branch that is called `bad-branch-name` and you want to change it to `corrected-branch-name`, while keeping all history. You also want to change the branch name on the remote (GitHub, GitLab, other server). How do you do this? @@ -93,7 +93,7 @@ Rename the branch locally with the `git branch --move` command: $ git branch --move bad-branch-name corrected-branch-name ---- -This replaces your bad-branch-name with corrected-branch-name, but this change is only local for now. +This replaces your `bad-branch-name` with `corrected-branch-name`, but this change is only local for now. To let others see the corrected branch on the remote, push it: [source,console] @@ -113,10 +113,8 @@ $ git branch --all remotes/origin/main ---- -Notice that you're on the branch corrected-branch-name. -The corrected branch is available on the remote. -However the bad branch is also still present on the remote. -You can delete the bad branch from the remote: +Notice that you're on the branch `corrected-branch-name` and it's available on the remote. +However, the branch with the bad name is also still present there but you can delete it by executing the following command: [source,console] ---- @@ -131,19 +129,19 @@ Now the bad branch name is fully replaced with the corrected branch name. ==== Changing the name of a branch like master/main/mainline/default will break the integrations, services, helper utilities and build/release scripts that your repository uses. Before you do this, make sure you consult with your collaborators. -Also make sure you do a thorough search through your repo and update any references to the old branch name in your code or scripts. +Also, make sure you do a thorough search through your repo and update any references to the old branch name in your code and scripts. ==== -Rename your local _master_ branch into _main_ with the following command +Rename your local `master` branch into `main` with the following command: [source,console] ---- $ git branch --move master main ---- -There's no _master_ branch locally anymore, because it's renamed to the _main_ branch. +There's no local `master` branch anymore, because it's renamed to the `main` branch. -To let others see the new _main_ branch, you need to push it to the remote. +To let others see the new `main` branch, you need to push it to the remote. This makes the renamed branch available on the remote. [source,console] @@ -162,10 +160,10 @@ git branch --all remotes/origin/master ---- -Your local _master_ branch is gone, as it's replaced with the _main_ branch. -The _main_ branch is also available on the remote. -But the remote still has a _master_ branch. -Other collaborators will continue to use the _master_ branch as the base of their work, until you make some further changes. +Your local `master` branch is gone, as it's replaced with the `main` branch. +The `main` branch is present on the remote. +However, the old `master` branch is still present on the remote. +Other collaborators will continue to use the `master` branch as the base of their work, until you make some further changes. Now you have a few more tasks in front of you to complete the transition: @@ -176,7 +174,7 @@ Now you have a few more tasks in front of you to complete the transition: * Update references to the old branch in documentation. * Close or merge any pull requests that target the old branch. -After you've done all these tasks, and are certain the main branch performs just as the _master_ branch, you can delete the _master_ branch: +After you've done all these tasks, and are certain the `main` branch performs just as the `master` branch, you can delete the `master` branch: [source, console] ----