Skip to content

Commit

Permalink
Merge branch 'jc/rebase-orig-head'
Browse files Browse the repository at this point in the history
* jc/rebase-orig-head:
  Documentation: mention ORIG_HEAD in am, merge, and rebase
  Teach "am" and "rebase" to mark the original position with ORIG_HEAD
  • Loading branch information
Junio C Hamano committed Jul 15, 2008
2 parents 0557671 + 9869099 commit 633ce9a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 3 deletions.
6 changes: 6 additions & 0 deletions Documentation/git-am.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ directory exists, so if you decide to start over from scratch,
run `rm -f -r .dotest` before running the command with mailbox
names.

Before any patches are applied, ORIG_HEAD is set to the tip of the
current branch. This is useful if you have problems with multiple
commits, like running 'git am' on the wrong branch or an error in the
commits that is more easily fixed by changing the mailbox (e.g.
errors in the "From:" lines).


SEE ALSO
--------
Expand Down
4 changes: 3 additions & 1 deletion Documentation/git-merge.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ Otherwise, merge will refuse to do any harm to your repository
(that is, it may fetch the objects from remote, and it may even
update the local branch used to keep track of the remote branch
with `git pull remote rbranch:lbranch`, but your working tree,
`.git/HEAD` pointer and index file are left intact).
`.git/HEAD` pointer and index file are left intact). In addition,
merge always sets `.git/ORIG_HEAD` to the original state of HEAD so
a problematic merge can be removed by using `git reset ORIG_HEAD`.

You may have local modifications in the working tree files. In
other words, 'git-diff' is allowed to report changes.
Expand Down
3 changes: 2 additions & 1 deletion Documentation/git-rebase.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ of commits that would be shown by `git log <upstream>..HEAD`.

The current branch is reset to <upstream>, or <newbase> if the
--onto option was supplied. This has the exact same effect as
`git reset --hard <upstream>` (or <newbase>).
`git reset --hard <upstream>` (or <newbase>). ORIG_HEAD is set
to point at the tip of the branch before the reset.

The commits that were previously saved into the temporary area are
then reapplied to the current branch, one by one, in order. Note that
Expand Down
1 change: 1 addition & 0 deletions git-am.sh
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ else
: >"$dotest/rebasing"
else
: >"$dotest/applying"
git update-ref ORIG_HEAD HEAD
fi
fi

Expand Down
1 change: 1 addition & 0 deletions git-rebase--interactive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ EOF
has_action "$TODO" ||
die_abort "Nothing to do"

git update-ref ORIG_HEAD $HEAD
output git checkout $ONTO && do_rest
;;
esac
Expand Down
2 changes: 1 addition & 1 deletion git-rebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ fi
echo "First, rewinding head to replay your work on top of it..."
git checkout "$onto^0" >/dev/null 2>&1 ||
die "could not detach HEAD"
# git reset --hard "$onto^0"
git update-ref ORIG_HEAD $branch

# If the $onto is a proper descendant of the tip of the branch, then
# we just fast forwarded.
Expand Down

0 comments on commit 633ce9a

Please sign in to comment.