Information Technology Reference
In-Depth Information
Create the repository shown in Figure 8-9(a) with the following commands:
$ cd git-recipes
$ git init 08-09
$ cd 08-09
$ git simple-commit m1 m2 m3
$ git checkout -b feature
$ git simple-commit f1 f2 f3
$ git checkout master
$ git simple-commit m4 m5
$ git merge feature
$ git branch -d feature
$ git simple-commit m6
Verify that the history of your repository looks like Figure 8-9(a) with the $ git
log --oneline --graph command. You also can list the contents of the working
directory with $ ls . The working directory now contains nine files: f1.txt through
f3.txt and m1.txt through m6.txt .
When the repository is ready you can revert the merge commit with:
$ git revert --no-edit -m 1 HEAD
The command moves the history forward. The repository will now contain a new re-
vision with the comment Revert "Merge branch 'feature'" . This revision
removes all the changes introduced in commits that you created in feature branch.
The working directory now contains only six files m1.txt through m6.txt . The files
f1.txt , f2.txt , and f3.txt are gone. You can verify it with the $ ls command.
How It Works
Merge commits have two or more parents. If you revert a merge commit you have to
indicate which part of the history should be reverted. The commit labeled as Merge
branch ' feature ' in Figure 8-9 has two parents:
• The first is the commit m5
• The second parent is the commit f3
Search WWH ::




Custom Search