Examples below will use the following branches:
- master
- staging
- 123-new-docs
- 127-bug-fix
The script will provide the output from git and also from the script. Any conflicts found will halt the script until you fix them.
This command can accept two arguments:
- comma-delimited list of branches to merge into (defaults to all branches other than master or production)
- branch to merge from (defaults to production or master)
Finds master branch (named production or master) and all other local branches. Merges master into other locals and pushes.
$ gam
Starting to auto-merge of `master` into all other local branches...
Switched to branch '123-new-docs'
Already up-to-date.
Everything up-to-date
Switched to branch '127-bug-fix'
Already up-to-date.
Everything up-to-date
Switched to branch 'staging'
Already up-to-date.
Everything up-to-date
Auto-merge complete...
This will merge the master branch found only into the branches you specify.
As you will see if skips the staging
branch this time.
$ gam "123-new-docs,127-bug-fix"
Starting to auto-merge of `master` into all other local branches...
Switched to branch '123-new-docs'
Already up-to-date.
Everything up-to-date
Switched to branch '127-bug-fix'
Already up-to-date.
Everything up-to-date
Auto-merge complete...
This will merge a different branch (that you specify) into all other branches. You can use this if you want to merge a branch other than master
or production
.
As you will see it uses 127-bug-fix
to merge from this time.
$ gam "" "127-bug-fix"
Starting to auto-merge of `127-bug-fix` into all other local branches...
Switched to branch '123-new-docs'
Already up-to-date.
Everything up-to-date
Switched to branch 'master'
Already up-to-date.
Everything up-to-date
Switched to branch 'staging'
Already up-to-date.
Everything up-to-date
Auto-merge complete...
This will merge a custom branch into only the other branches you specify.
As you will see it skips merging 127-bug-fix
into the master
branch.
$ gam "123-new-docs,staging" "127-bug-fix"
Starting to auto-merge of `127-bug-fix` into all other local branches...
Switched to branch '123-new-docs'
Already up-to-date.
Everything up-to-date
Switched to branch 'staging'
Already up-to-date.
Everything up-to-date
Auto-merge complete...
If the master branch to be used does not exist in your local branches the script will exit.
$ gam "" "fail-branch"
Fatal: The branch `fail-branch` to be used for merging from does not exist.
A notice will display to terminal but not stop the process from running. These happen when trying to merge into a branch that does not exist or if trying to merge into master from master (only one branch in repo).
$ gam "154-does-not-exist,staging"
Starting to auto-merge of `master` into all other local branches...
Notice: `154-does-not-exist` does not exist, skipping merge for this branch.
Already on 'staging'
Already up-to-date.
Everything up-to-date
Auto-merge complete...