Skip to content

Instantly share code, notes, and snippets.

@miekg
Created December 4, 2023 16:09
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 miekg/a980f565d29e1bc3e766f5bb4302ed7b to your computer and use it in GitHub Desktop.
Save miekg/a980f565d29e1bc3e766f5bb4302ed7b to your computer and use it in GitHub Desktop.
git config
# Fetch a mr/pr number from the hub and check it out in either mr-<num> or pr-<num> branch
pr = "!f() { \
case $(git hubtype) in \
github) git githubpr;; \
gitlab) git gitlabpr;; \
esac; \
}; f"
gitlabpr = "!f() { pr=$(basename $1); git fetch origin pull/$pr/head:pr-$pr && git checkout pr-$pr; }; f"
githubpr = "!f() { mr=$(basename $1); git fetch origin merge-requests/$mr/head:mr-$mr && git checkout mr-$mr; }; f"
hubtype = "!f() { case $(git remote get-url origin) in *github*) echo github;; *gitlab*) echo gitlab;; esac; }; f"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment