Git alias for checking out pull requests
To fetch a pull requests by its ID, I probably googled “github checkout pull
request” a hundred times by now. Here is a simple Git alias which goes into the
.gitconfig
to make that a bit easier:
[alias]
checkout-pr = "!f() { git fetch origin pull/$1/head:pr-$1 && git checkout pr-$1; }; f"
Now it’s just a matter of git checkout-pr 42
to check the changes of pull
request #42 on my local system.