The mind is like a parachute. If it doesn't open, you're meat.

Adventures in Azure DevOps: I git too fast

18 Jun 2019

I like keeping the number of commits in my pull requests in the low single digits, preferably 1. For context see the post on my disaster resistant git workflow.

I used to do all the work, squashing the commits at the end of the work before merging my pull requests but recently I have switched to using git commit --amend.

The reason for this is that while I have noticed that I rarely need to re-arrange my commits in logical groups when squashing (call it a benefit of experience - it certainly was not like this years ago), I make a lot of typing and syntax errors.

As a result my typical change originally looks like

c31e548 Some informed and wise comment on the change
dfdfd15 typo
d19f4f1 typo
7122e4a typo fix
a62803a syntax fix
53b99b8 dammit
c657575 why didn't this work?
d8e72cf doh, PEBKAC
5017515 what an idiot
59c53d1 stupid semicolon
db6aa1c I hate ...
47d3dc7 AAAARGH
4640d92 done

Previously I would be kind and squash, but you could follow everything in the pull request notifications. --amendallows me to appear infalible :D.

As an added optimization (remember, I usually do builds and CI and stuff like that - my code does not need the CI, it IS the CI) I recently added an alias to my collection:

$ git config alias.cowboy
!git commit --amend && git push -f

As a measure of sparing me a few keystrokes it is great (remember, I typo a lot). As a practice it is questionable, but see in which context it is used in the aforementioned git workflow post.

Funnily, in Azure Devops I get to trip myself up with this.

Checkout error

Today I started with builds failing on checkout, which was wierd.

Looking closer it gets momentarily even wierder:

fatal: reference is not a tree

What happened

Basically my cowboy ways pulled the rug from under git's feet.

What you see is a live demostration of the dangers of rewriting history in git.

The build is setup with a stage of 5 jobs but for the moment we only have a pool of 2 agents. So if I catch my typo fast enough and play the cowboy card the running build will try to get a SHA that does not exist anymore.

No harm done other than a negative skew on my successfull build percentage.

Everything is fine, we're all professionals here.

blog comments powered by Disqus