Information Technology Reference
In-Depth Information
after next the fetch command. The commands to delete remote branches will be dis-
cussed in chapter 10 concerning synchronization of repositories.
5-10. Using a branch as a backup
Problem
Your repository is in clean state. You start to work on a new feature in your current
branch. After some revisions you realize the new idea is not working and want to dis-
card it. You want to cancel the new feature and return your repository to the state just
before the feature was started. The best solution to this problem is to use branches.
Solution
Clone the repository created in Recipe 5-1 with all the branches:
$ cd git-recipes
$ git clone-with-branches 05-01 05-10
$ cd 05-10
The repository is now clean and you are in master branch. This is the starting
point. You create a new branch named feature that will be identical as the current
master branch:
$ git checkout -b feature
Now, you are in feature branch and create some commits:
$ git simple-commit one two three
All your modifications are committed, the repository is clean.
Now you decide that the whole concept implemented in the feature branch is not
working. And you want to get rid of it. You can achieve this with two commands:
Search WWH ::




Custom Search