Create merge request to target branch automatically
Jul 22, 2024/
#git
/-1 minIf you hate opening MR from the Gitlab interface after pushing the branch like I do, the following code fragment will do the trick.
1git push \
2 -o merge_request.create \
3 -o merge_request.remove_source_branch \
4 -o merge_request.merge_when_pipeline_succeeds \
5 -o merge_request.target=master \
6 -o merge_request.assign=$(git config user.email | cut -d “@” -f 1) \
7 -o merge_request.title="${TITLE}”
You can then assign an alias to this script to simplify its use.
1alias gpm='git_push_to_master'
2git_push_to_master ()
3{
4 git push --no-verify \
5 -o merge_request.create \
6 -o merge_request.target=master \
7 -o merge_request.assign=$(git config user.email | cut -d “@” -f 1) \
8 -o merge_request.title="$1”
9}
Put the above code in
~/.zshrc
and run source ~/.zshrc
.
You can now use it as follows.
1gpm “Test MR Title”