LinuxCommandLibrary

git-merge

Join development histories together

TLDR

Merge branch into current

$ git merge [branch-name]
copy
Merge with commit message
$ git merge [branch] -m "[message]"
copy
Merge without fast-forward
$ git merge --no-ff [branch]
copy
Squash merge
$ git merge --squash [branch]
copy
Abort merge
$ git merge --abort
copy

SYNOPSIS

git merge [options] [commit]

DESCRIPTION

git merge joins two or more development histories together. It combines the specified branch and its history into the current branch, creating a merge commit when the histories have diverged.
Fast-forward merges simply move the branch pointer forward without creating a merge commit. The `--no-ff` flag forces a merge commit even when fast-forward is possible, preserving branch topology. Squash merges (`--squash`) combine all changes into a single staged changeset without creating a merge commit.

PARAMETERS

COMMIT

Branch or commit to merge.
--no-ff
Always create merge commit.
--ff-only
Only fast-forward merge.
--squash
Squash commits into one.
-m MESSAGE
Merge commit message.
--abort
Abort current merge.
--continue
Continue after conflict resolution.
-s STRATEGY
Merge strategy.
--help
Display help information.

CAVEATS

Conflicts require manual resolution. Fast-forward may hide branch history. Merge commits can complicate history.

HISTORY

git merge is a core Git command from initial release, implementing the branch combination essential to git's distributed workflow.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community