This is a git workflow script that takes care of merging a feature branch into the main branch.
Term | Definition | Default |
---|---|---|
landing branch | The branch that is being landed | Current branch |
target branch | The branch that the landing branch is being landed to | main |
remote | The remote that the changes can be automatically pushed to | origin |
- Verify if the landing branch (the current branch or a specified branch) is clean.
- Get the target branch and try to fast-forward it from the remote.
- Rebase the landing branch on target branch.
- Merge the landing branch into the target branch with
--squash
. - Commit.
- Delete the landing branch.
- Optionally, push the changes to the remote.
Every step must finish without conflicts, otherwise the workflow cleans up, restores the previous state, and errors out.
To install the script, download it to any directory that is in your PATH
.
For example:
curl -o /usr/sbin/git-land https://raw.githubusercontent.com/b4nt0/git-land-branch/main/git-land
chmod +x /usr/sbin/git-land
The basic command to land a branch is just git land
.
This command will land the current branch onto main
.
To review the available options, run git land --help
.
By default, git-land
uses origin
as the remote. To use a different git remote, set the git-land.remote
option, for example:
git config git-land.remote upstream
By default, git-land
lands onto the main
branch. To use a different landing destination, set the git-land.target
option, for example:
git config git-land.target master
To use git-land
, run:
git land [options] [<comment> [<branch>]]
where:
<comment>
is the landing commit comment
<branch>
is the name of the landing branch
and the options are:
Option | What it does |
---|---|
-h |
Displays the help text |
--push |
If set, git-land would automatically push the changes to the remote |
--verbose |
Enables verbose output |
--paranoid |
Asks for user confirmation for every write command |
This command is inspired by the git-land
script made by Bazaarvoice, Inc., RetailMeNot, Inc., and other contributors.