Skip to content

Commit

Permalink
Merge branch 'kh/merge-tree-doc' into maint-2.47
Browse files Browse the repository at this point in the history
Docfix.
cf. <CABPp-BE=JfoZp19Va-1oF60ADBUibGDwDkFX-Zytx7A3uJ__gg@mail.gmail.com>

* kh/merge-tree-doc:
  doc: merge-tree: improve example script
  • Loading branch information
gitster committed Nov 25, 2024
2 parents bd8a8a7 + c4b8fb6 commit fd78021
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Documentation/git-merge-tree.txt
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,15 @@ linkgit:git-commit-tree[1], linkgit:git-write-tree[1],
linkgit:git-update-ref[1], and linkgit:git-mktag[1]. Thus, it can be
used as a part of a series of steps such as:

NEWTREE=$(git merge-tree --write-tree $BRANCH1 $BRANCH2)
test $? -eq 0 || die "There were conflicts..."
NEWCOMMIT=$(git commit-tree $NEWTREE -p $BRANCH1 -p $BRANCH2)
vi message.txt
BRANCH1=refs/heads/test
BRANCH2=main
NEWTREE=$(git merge-tree --write-tree $BRANCH1 $BRANCH2) || {
echo "There were conflicts..." 1>&2
exit 1
}
NEWCOMMIT=$(git commit-tree $NEWTREE -F message.txt \
-p $BRANCH1 -p $BRANCH2)
git update-ref $BRANCH1 $NEWCOMMIT

Note that when the exit status is non-zero, `NEWTREE` in this sequence
Expand Down

0 comments on commit fd78021

Please sign in to comment.