Information Technology Reference
In-Depth Information
Thanks to piped sort and uniq commands, the output produced by the command
from Listing 7-1 will contain every commit exactly once.
Listing 7-1. The command to list all the reflog commits with comments containing f3
$ git log --walk-reflogs --grep=f3 --pretty="%h %s %cd" |
sort | uniq
When you find the correct commit, you can change the feature branch using the
$ git reset --hard [SHA-1] command. If your repository is clean this com-
mand can be regarded as a way to move your current branch to arbitrary revision. The
same effect can be also accomplished with two separate commands:
$ git branch -D feature
$ git checkout -b feature [SHA-1]
The first command deletes the feature branch; the second creates a new fea-
ture branch pointing to the desired revision. You can combine both above commands
into one:
$ git checkout -B feature [SHA-1]
The switch -b is a safe one: it creates a branch only if the repository doesn't already
contain such a branch. If the branch exists, $ git checkout -b fails. The switch
-B forces the $ git checkout command to override the existing branch.
Okay, we know how rebasing converts the structure of the graph of revisions. But
what happens to the files? In this sense, the result of rebasing produces exactly the
same results as merging. Both commands:
# current branch is feature
$ git rebase master
$ git merge master
result in exactly the same contents of the working directory. The working directory
contains files from both branches: feature and master .
In general, the rebasing depicted in Figures 7-2 and 7-3 operates on two branches;
therefore the command expects two parameters:
 
Search WWH ::




Custom Search