Earlier today I tweeted how to preview a Git pull request. It got a few retweets and favourites quite quickly, so I thought I’d share a few other tricks, as well as the one I tweeted.
Some are basic tips, but ones that I spent a while finding and learning, and some are tips I have learnt from the awesome team I work with . If your Git-fu is amazing, you can probably skip them.
‘Upstream’ is the term we use for the original repo. ‘Origin’ is the version of the repo that you have after forking. ‘Upstream’ is the repo that you forked in the first place.
Once set, you can use ‘upstream’ instead of a URL. You’ll need this set for each repo for a lot of the below tips to work.
Preview a Pull Request
Let’s say you want to locally run a pull request to see how it works, before you merge it. How do you do that without forking their repo and running that? This, is how you do it.
Create & Delete a Tag
Tagging code is a good way to say “Okay, that’s feature X done, let’s tag it so people can download or run it from this point back”. It’s exactly what we do with Ghost and Ghost-UI, though releases of Ghost-UI happen much more often to give contributors styles to work with.
There’s many reasons why you’ll want to rename a branch. You can rename another branch or the currently checked out branch.
#protip: Think of
From any branch
From current branch
This is how you merge commits together. If you ever contribute to Ghost, you’ll need this one.
Everyone likes a clean commit history.
Lets say you want to pick a few select commits from one branch to the other, cherry-pick is your friend.
For this to work, you need to be on a different branch to the one your picking commits from. You can either use the first 10 characters from a commit hash, or the full 40 characters.
Reset to upstream
Let’s say you’re totally fucked. Like, no one has any clue. You haven’t done much work that would be disastrous to loose. Reset to upstream!
Use this with caution. You could loose days of work.
Well, there’s enough tips for today. Do drop me a tweet if you see any seriousl flaws with these tips. 🙂