Merging

Merging

Merge a feature branch into main

$ git switch main
$ git merge feature/name

Force a merge commit (no fast-forward)

$ git merge --no-ff feature/name

Squash a branch into a single commit

$ git merge --squash feature/name
$ git commit -m "Add feature"

Abort a conflicted merge

$ git merge --abort

Returns everything to the pre-merge state.

Resolve a merge conflict

$ git status                        # identify conflicting files
# ... edit each file, remove markers ...
$ git add <file>                    # stage resolved file
$ git commit                        # complete the merge
On this page