Skip to content

Instantly share code, notes, and snippets.

@helpermethod
Last active January 10, 2019 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save helpermethod/6445f2635937407e7d9b0b9f989d706f to your computer and use it in GitHub Desktop.
Save helpermethod/6445f2635937407e7d9b0b9f989d706f to your computer and use it in GitHub Desktop.
Open a new GitLab Merge Request from the command line

Add the following shell function to your .bashrc.

mr() {
  local url=$(git remote get-url origin)

  # on OSes other than Mac OS X replace `open -a "Google Chrome` with your browsers executable, e.g. google-chrome on Ubuntu
  open -a "Google Chrome" "${url%.git}/merge_requests/new?merge_request[source_branch]=$(git symbolic-ref -q --short HEAD)"
}

Source your .bashrc.

$ . .bashrc

After you have pushed a commit, type mr on the commandline.

$ git commit -a -m 'Update README.md'
$ git push
$ mr

A browser window with the new Merge Request will open in your browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment