Information Technology Reference
In-Depth Information
branch you merge in doesn't change—it still points to the same revision as before the
command. The branch you merge into receives a new commit with comment similar to:
Merge branch 'X'
where the X is the name of the branch you merged in ( feature , in our recipe). You
can memorize the above rules, remembering that, when on the master branch, the $
git log --oneline -1 command prints:
6fb2 Merge branch 'feature'
As you can guess the working directory now contains all the files from both
branches. The command $ ls outputs the files: f1.txt , f2.txt , f3.txt ,
m1.txt , m2.txt , m3.txt , m4.txt , m5.txt .
The merge can be undone exactly as in Recipe 6-3. Only this time you can use not
only reflog and SHA-1, but also ancestor and n-th parent references. Assuming that
you are in the master branch both the following commands will undo the merge dis-
cussed in this recipe:
$ git reset --hard master^
$ git reset --hard master
However, if you work in Windows command line, things are complicated. Because
the caret is a special character you will have to use it in a special way. The caret is used
by Windows shell parser as an escaping character. In Linux shells this role is usually
assigned to the backslash (\) character. If you want to use the caret in Windows com-
mand line you have to type it twice (^^). Moreover, because on Windows git subcom-
mands are fired through an indirect shell call, the escaping is performed twice. As a
result, if you want to use the reference master^2 in Windows command line, you
have to type four carets master^^^^2 . Of course, this does not apply if you work in
bash shell.
The funniest situation like this occurs when you want to use backslash ( \) in a reg-
ular expression in an SQL statement embedded in a string, such as:
$query = "SELECT * FROM paradox WHEARE content REGEXP
'\\\\\\\\'";
Search WWH ::




Custom Search