| 240 | As a variation of the above, git alias can be set in git configuration file to make this even easier. Add following lines to either $HOME/.gitconfig (all git repositories) or .git/config (in source repository): |
| 241 | |
| 242 | {{{ |
| 243 | [alias] |
| 244 | pr = "!f() { git fetch -fu ${2:-upstream} refs/pull/$1/head:pr/$1 && git checkout pr/$1; }; f" |
| 245 | pr-clean = "!git checkout master ; git for-each-ref refs/heads/pr/* --format=\"%(refname)\" | while read ref ; do branch=${ref#refs/heads/} ; git branch -D $branch ; done" |
| 246 | }}} |
| 247 | |
| 248 | How to use the aliases: |
| 249 | {{{ |
| 250 | # Fetch and checkout a PR: |
| 251 | git pr <id> # (e.g. git pr 832) |
| 252 | |
| 253 | git branch -a |
| 254 | master |
| 255 | * pr/832 |
| 256 | pr/837 |
| 257 | releasebranch_7_6 |
| 258 | releasebranch_7_8 |
| 259 | |
| 260 | # Delete all PRs: |
| 261 | git pr-clean |
| 262 | }}} |
| 263 | |
| 264 | Note: to be on the safe side, only use this for testing pull request! |
| 265 | |