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. Images as the first thing in a button or link

    If the text of an interactive element like a button or link is preceded with an accessible image, we’ve probably got an accessibility problem.

  2. Alt text for CSS generated content

    There’s an interesting feature in Safari 17.4 that allows content added with CSS to have ‘alt’ text. I’m not sure how I feel about this.