Information Technology Reference
In-Depth Information
$ git checkout master
$ git branch -D feature
How It Works
You don't need new commands for this recipe. This recipe only underlines the useful-
ness of branches in a specific scenario. Without risk, git allows you to test new con-
cepts that would otherwise destroy or complicate your work. Every branch is independ-
ent of other branches. The modifications you commit in the feature branch do not
affect the master branch or, in fact, any other branch. If some specific state of your
repository is important to you, and you want to be absolutely sure that whatever you
do, you can always get it back, just create a branch. It's as simple as that. Once you
grasp this idea, you will wonder, how on earth you managed to work without it.
Remember that if you are not sure about an idea, you don't have to delete the
branch. Superfluous branches don't influence your work in any way. You can leave
them alone. A branch written in loose format only consumes 41 bytes, so it does not
consume a lot of space.
Finally, if you delete the branch the revisions you created are not removed from a
database, even if you prune it. The reason is simple: reflog contains entries that forbid
pruning these objects. To completely remove the branch and its revisions you have to
delete a branch, clear the reflog, and prune the database.
5-11. Renaming branches
Problem
You work in a repository shown in Figure 5-1 , and you want to rename branches:
info to information
master to doc
Solution
Clone the repository created in Recipe 5-1:
Search WWH ::




Custom Search