LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

git-graft

Merge a branch and delete it immediately

TLDR

Graft a branch into the current branch
$ git graft [feature-branch]
copy
Graft a branch into a specific destination branch
$ git graft [feature-branch] [dest-branch]
copy

SYNOPSIS

git graft src-branch [dest-branch]

DESCRIPTION

git graft merges a branch then immediately deletes it, combining git merge followed by git branch -d into a single operation. It is useful for incorporating completed feature branches into the main history while cleaning up branch clutter.
Part of the git-extras suite, the command simplifies the common merge-and-delete workflow for branches that should become part of history without keeping the branch reference.

PARAMETERS

src-branch

The branch to merge and then delete
dest-branch
The branch to merge into (defaults to the current branch)

CAVEATS

Requires the git-extras package. The source branch is deleted after merge. Only use for completed work where the branch reference is no longer needed. The merge must be a clean fast-forward or merge commit; conflicts will cause failure.

SEE ALSO

Copied to clipboard
Kai