Skip to contents

Use git_merge to merge a branch into the current head. Based on how the branches have diverged, the function will select a fast-forward or merge-commit strategy.


git_merge(ref, commit = TRUE, squash = FALSE, repo = ".")

git_merge_stage_only(ref, squash = FALSE, repo = ".")

git_merge_find_base(ref, target = "HEAD", repo = ".")

git_merge_analysis(ref, repo = ".")

git_merge_abort(repo = ".")



branch or commit that you want to merge


automatically create a merge commit if the merge succeeds without conflicts. Set this to FALSE if you want to customize your commit message/author.


omits the second parent from the commit, which make the merge a regular single-parent commit.


The path to the git repository. If the directory is not a repository, parent directories are considered (see git_find). To disable this search, provide the filepath protected with I(). When using this parameter, always explicitly call by name (i.e. repo = ) because future versions of gert may have additional parameters.


the branch where you want to merge into. Defaults to current HEAD.


By default git_merge automatically commits the merge commit upon success. However if the merge fails with merge-conflicts, or if commit is set to FALSE, the changes are staged and the repository is put in merging state, and you have to manually run git_commit or git_merge_abort to proceed.

Other functions are more low-level tools that are used by git_merge. git_merge_find_base looks up the commit where two branches have diverged (i.e. the youngest common ancestor). The git_merge_analysis is used to test if a merge can simply be fast forwarded or not.

The git_merge_stage_only function applies and stages changes, without committing or fast-forwarding.