Skip to main content

On not setting an upstream for short-lived branches

Posted in Development and Git

I tried GitHub Flow a while ago, and, although it’s a simpler process, it involved some automation (using GitHub Actions) which I’m yet to delve into, so I’m back using my trusty old Git Flow workflow.

A few weeks ago, I wrote about setting an upstream on a local Git branch, where I said:

if I know I’ll be pushing and pulling a fair bit over the life of a feature (or setting up a ‘forever’ branch like develop or staging), setting an ‘upstream’ makes things quicker

There’s a bit more to say about my work where I don’t set an upstream. All I’d have to do is add the -u flag and never have to write the origin my-great-feature bit of the command again, so why wouldn’t I add it?

Since I’m using Git Flow, I rarely need to push more than once; after that first push I head to GitHub, raise a pull request, and so on.

The only time I might have to push from a branch a second time would be if I’ve forgotten to add something, or if some tests failed and I have to fix something. In those situations, I sort of like the extra effort of having to type out git push origin my-great-feature in full. That tiny bit of extra effort helps train me to avoid making the mistake again in future, meaning fewer commits overall and, therefore, an easier to read history.

Also, if you add up the overall number of times I’d have to type those three characters ( , -, u) versus the characters in origin my-great-feature (or whatever the branch name might be), I’d definitely end up typing more if I set an upstream every time. So not setting an upstream is more efficient!

My stance on setting an upstream will probably change when I made a concerted effort to use get to grips with GitHub Actions and use the GitHub Flow workflow again; GitHub flow involves lots of pushing to the server as work is committed. But, for now, I won’t be setting any upstreams for short-lived feature branches.

Accessibility in your inbox

I send an accessibility-centric newsletter on the last day of every month, containing:

  • A roundup of the articles I’ve posted
  • A hot pick from my archives
  • Some interesting posts from around the web

I don’t collect any data on when, where or if people open the emails I send them. Your email will only be used to send you newsletters and will never be passed on. You can unsubscribe at any time.

More posts

Here are a couple more posts for you to enjoy. If that’s not enough, have a look at the full list.

  1. Upgrading from iPhone 13 mini to 16 Pro

    I get a new phone every 3-ish years, give mine to my wife, and now she gives hers to our daughter. I got a 16 Pro this year! Here’s the skinny.

  2. Apple, you’re doing the Dynamic Island wrong

    I love the idea of Dynamic Island; making lemons into lemonade and all that. But, in my opinion, Apple have got the fundamentals mixed up.