Articles and resources in the Git category. A full list of categories is also available.
git restoreis great, and one of its superpowers is its patch mode where we can restore parts of a file, rather than the whole file at once.
I’ve talked about how great
git restoreis, but I missed a really obvious use of
git restore: restoring a deleted file!
I no longer use
git checkoutto switch branches; I’ve also stopped using it to discard uncommitted changes: let me introduce
Since upgrading to macOS Big Sur, I’ve noticed that
git switchworks. But why do we need it when we’ve got
Have you ever made a bunch of commits on the wrong branch? I certainly have… Luckily, there’s an easy way to put things right.
I only set upstream Git branches when I need to push and pull a lot, otherwise I prefer to write out my target branch manually. Here’s why…
When you rename your Git branch, you’re going to need to reconfigure any Netlify deployments that are set up to watch your old
There’s no such thing as syncing in Git, but setting an upstream branch is about as close as it gets.
mainis a good idea, but how do we do it? Fortunately, it’s really straightforward if your repository lives on GitHub.
I’ve noticed a move towards renaming the
masterGit branch. It’s a racially charged term and I’m very happy to switch from
Naming stashes is a good idea if some time is likely to pass between stashing and picking up the work again, but sometimes we need even more info.
If you stash a lot, or need to apply a stash non-destructively you might eventually want to clear things down to keep your stash list tidy.
You’ll almost always want to delete a stash when you apply it, but if for some reason you need to keep the stash around, Git lets you do that.
Naming your Git stashes can be really helpful, especially if you’re stashing a lot or saving a stash to come back to another day.
Viewing all of a Git repository’s stashes and choosing one from the list is the next step I took in my Git stash on the command line journey.
I’ve put it off for the longest time, but it turns out stashing changes with Git on the command line is surprisingly easy to get the hang of.
When you enter Git’s patch mode, the chunks of code you’re offered to stage/skip can sometimes be too big. Here’s how splitting them works.
Since moving to command line Git, I’ve avoided patch mode; it looked too complicated. Turns out it’s really not, and very much worth learning.
When you need to dig out a commit you made a long time ago, you’re going to need something a bit more powerful than a standard
I’m still writing my Git commands long-hand. Turns out a fetch and prune can be more concise than I’ve previously suggested, all without aliases.
Writing a sequence of Git commands is really handy and much quicker than running one, waiting for it to finish, writing the next, etc. Here’s how.
When using Git, you’ll normally push work to an identically named branch on your remote, but what if you want to push to a different branch?
git statusis one of the Git commands I use the most, but I’ve always thought that it overshares. Well, I’ve found a way to make it more readable!
The whole point of a PR is to get feedback and approval on a piece of work from someone else before it’s published. But what if it’s just you?
Renaming a Git repository feels pretty fundamental – surely something will break? Well, worry no more – it turns out it’s a piece of cake!
Turns out it’s pretty easy to look at the differences between two branches in Git. This is useful when coming back to a feature branch after a while.
There are two ways to get a branch up to date with master before raising a PR: merge and rebase. Here are pros and cons with each.
I’ve started using GitHub Flow for some projects and the process is much simpler than GitFlow, but one hurdle I encountered was tagging.
GitFlow is great but it’s not quite right for every project. GitHub Flow is simpler and means I’ll publish a feature or fix as soon as it’s ready.
It can be fiddly to stage files for a commit using Git on the command line. Or so I thought! I found a shortcut, so thought I’d write about it.
Git aliases are incredibly useful, but there are five good reasons I’ve decided not to make use of them.
Git workflows like GitFlow are great, but how does publishing articles fit in when using a static site generator? Here’s how I’m doing it.
Something that has been bugging me since moving from a GUI to command line git has been the default editor for writing commit messages.
Since I’ve started using Git on the command line, there’s one ‘new’ thing that I’ve used more than any other: amending my most recent commit.
This week I removed some files and data from my Git history. It was a bit of a learning curve, but here’s how I did it, step by step.
I’ve been using Git for years and it’s finally time to make a concerted effort to move away from my GUI to the command line.