LinuxCommandLibrary

git-merge

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 development histories together. It combines the specified commit and its history into the current branch, creating a merge commit when necessary.
Fast-forward merges move the branch pointer without creating a commit. Non-fast-forward merges create explicit merge commits. Squash merges combine all changes into one commit.
git merge is fundamental to branch-based workflows.

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

Copied to clipboard