You can do this by adding push-options -o OPTION directly via CLI when pushing or setting them globally in your .gitconfig file.
For example, when using GitLab adding the following options to gitconfig:
[push]
pushOption = merge_request.create
pushOption = merge_request.target=main
pushOption = merge_request.squash
pushOption = merge_request.merge_when_pipeline_succeeds
pushOption = merge_request.remove_source_branch
pushOption = merge_request.title="TODO CHANGE ME"
pushOption = merge_request.draft
after each push you will:
- automatically create a draft MR
- set target branch main
- set title "TODO CHANGE ME"
- assign it to you (and respect any MR template you have eg for default reviewers)
- set the flags to squash commits on merge
- set the flag to delete source branch on merge
- enable the automerge when all configured checks (pipeline success, required approvals, etc) pass
This small automation will likely help you speed up your development and help you include the CM concepts in your CICD pipelines