TOOL » GIT

Merge

Usage

Merges a source branch into the current branch.

shell
git merge OPTIONS SOURCE_BRANCH
OptionDescription
--squashPerform the merge but do not commit.
--no-ffForce creating a merge commit.
-s --strategyUse the given merge strategy.
--abortAbort a merge with conflicts.

Examples

Conflict resolution

Make sure all conflicts were resolved by running:

shell
git grep -HE '<{7} HEAD'

To commit with the default merge message:

shell
git commit --no-edit

Overwrite branch

Using -s ours discards everything the other tree did, declaring our history contains all that happened in it.

Example: Suppose there are two branches keep overwrite that cannot be merged because of conflicts. The changes in overwrite are not needed anymore, and you just want to update it to keep.

shell
git switch keep
git merge -s ours overwrite
git switch overwrite
git merge keep