I have been using Git a long, long time. I have worked on Git clients and libraries. At some places I've worked, I am the person folks go to when they need Git help.

And yet, only today I learned you can pass -m to commit twice (or more) and it will do the right thing of making each successive message a new paragraph (which is useful for the convention of a short summary as a single first line and following paragraphs as a more detailed message).

@halfogre what!?!

Now Iโ€™m even more mad at all the times I muscle-memoried โ€™:q!โ€™ after a meticulous commit message 

@halfogre I hate to say "this changes everything", but... this changes everything

@halfogre I once somehow managed to create a local branch called "origin/master"

That was fun.

masto-gitsocial-bridge

bridge between mastodon and git social

jonny's computer website

@halfogre Same - worked a bit with git, and since learning it at uni, at every job since, I got rep of "git magician" for some reason. And while I am impostor-syndromeing about it, I learned recently a fun and useful thing about it:

Instead of push ... --force or -f you can also just use +branch-name in the command to convey that you want to force-push to remote branch with the same name. I'm still not using it often, but it's easier to write when I do it. 

@halfogre
I've contributed code to git and I didn't know that ๐Ÿ˜† Thanks ๐Ÿ‘๐Ÿผ
@halfogre TIL. I do not really know when I could use that, but it is interesting anyway.
@halfogre I learned that just last year and now I use it *all the time*. Welcome to efficiency ๐Ÿคฉ
@halfogre interesting. I commit from terminal and just start the commit message with a quote and press enter to break lines. it was quite an eye opener :)
@romunov @halfogre I thought this was a mind-blowing til but I do this too!
@halfogre I just wrap my message in quotes and freely use the enter key to create paragraphs. You obviously have to escape the quote if needed in the message but I find this way more intuitive.
@halfogre are you familiar with git alias? Thatโ€™s what simplified my life.
@halfogre oh whaaaaaat (signed a literal full time c-git contributor)
@halfogre mind blown ๐Ÿคฏ. I am pretty sure I only scratch the surface of git on a daily basis.
@halfogre @puresick I've worked with git for over 10 years and taught classes about it. I also did not know that! Thanks for sharing :-)
@halfogre I did not know this either! I myself am in a similar position at my job  thanks for sharing! #git
@halfogre I give git (mainly introduction) trainings and did not knew that! ๐Ÿ˜…๐Ÿ˜…๐Ÿ˜…
@halfogre another thing you can do, which I find _really helpful_ is even if you pass a -m, you can still pass a -e and itโ€™ll do the right thing. Super useful for when you start with a -m thinking this is going to be a simple message but then decide you want a full editor to flesh out more detail.
@halfogre oh interesting. Does it correctly format the paragraphs to the right number of columns if you do it this way? I hate going in to an editor to write my commit messages but judging line length from the command prompt is a PITA.
@megmac I havenโ€™t tried it, but I donโ€™t expect so. I will probably still go to the editor for longer descriptions, but for my usual practice of one really short line followed by a slightly longer line, it works well.

@megmac
I used to use -m flags but eventually switched to using an editor.

Why? Because most of my projects are solo and I don't want to use an issue tracker. Instead I prefer to provide the context right next to the changes. Using an editor makes me use the description field, too.

It's a bummer that GitHub throws away most of the conversation in a PR unless you remember to update the first message before merging.

You see, I want to keep the information offline (because Germany).

@halfogre

@megmac
That being said, combing through the documentation I can see that there are many gems most of us will never use.

I'd pick up a good book to learn some of them (most likely always behind the curve, but that doesn't matter much)

@halfogre

@halfogre do you find using -m twice (or more) easier than entering a multi-line string into the shell? (bash, zsh, etc will prompt for additional lines of quoted string if you just leave the quote open; I do that all the time on commit messages.)

(The main hassle with โ€œjust have a many line shell stringโ€ is you have to be careful not to prematurely close the quote by accident: which can require juggling โ€˜ and โ€œ for quoting.)

@ewenmcneill

> do you find using -m twice (or more) easier than entering a multi-line string into the shell

Yes, I do for my typical flow of one really short line followed by a still relatively short line. For longer stuff I just go to the editor.

I have never really done the open quote thing intentionally. Never felt natural to me. Editor feels more natural.

Lots of ways to do this, all just fine. I was just really surprised to find something new I didn't know about `commit`.

@halfogre Iโ€™ve gotten every used to multi line quotes in the shell (especially for awk / perl one liners), so it does feel natural to me. But I can see how itโ€™d feel weird without 20 years doing that :-)

Thanks for the explanation. Definitely useful to know about repeated -m doing the right thing. Even if I suspect Iโ€™d be more likely to use it in scripting than interactively ๐Ÿค”

@ewenmcneill Yeah, I don't know that I will use it all that often either. I have been doing this in the editor so long and habits are hard to break.

@halfogre woah.

I've also been a very long time git user and this was news to me as well. Amazing.

@halfogre I'm sorry, _what_?! I had no idea.
@halfogre I was going to give someone a git primer Friday, so prepared some reference slides. I'll have to include this in one of the extra slides
@halfogre I wonder if that's per the spec or just implementation specific?

@halfogre Looks like it's part of the spec. Not a fun read, but probably worth it.

https://git-scm.com/docs/git-commit

Git - git-commit Documentation

@halfogre Mind sincerely blown. I really wish git had a better UX sometimes.
@halfogre like you, Iโ€™ve been using git for a long time (15 years now!) and this is the first Iโ€™ve ever heard of this ๐Ÿคฏ
@halfogre You're three days ahead of me in learning this.
@halfogre I just learned abt that in ~August and it's a game-changing feature esp if one is using expressive commit messages.
@halfogre this goes right into my git cheat sheet, thank you ๐Ÿ™
@halfogre  Did not know that either. Thanks!๐Ÿ‘

@halfogre WHAT.

I use -m all the time!

@halfogre
I also did not know this, despite having worked with Git for the last 9 years or so.

Git, unfortunately, is what happens when developers think about functionality without thinking carefully about usability. It's probably an unpopular opinion on my part, but I'm not a n00b, I've used it a long time, and I still come to this conclusion. It's really capable, but it's truly terrible to work with.

@feoh

@spatula @halfogre @feoh Git is popular but very few people actually know how to use it. It is especially facepalm-worthy when the โ€œgit is the bestโ€-types blow away their clone because they donโ€™t know how to fix whatever they did.

FWIW, for all my personal projects I use Mercurial. It is so much saner you use - and the evolve extension is amazing. Going back to git feels like visiting the Stone Age.

@jeffpc I kind of feel like the people who are really enthusiastic about Git are the same people who think that making interview candidates write out the code to rebalance a binary tree offers a good predictor of future success with ordinary business problems.
@spatula You mean unimaginative trend-chasers? :)

@jeffpc Well, yes, that, and people who think that human beings manually moving pointers around is a good use of their time.

I've worked in this industry for 27 years, and I've never once rebalanced a binary tree.

@spatula Whenever I ask something along those lines, the I'm looking for a "I'd use a library or whatever code already exists that is well exercised/tested".

Similarly, when I'm the candidate, that's my answer to questions like that. I've *always* had the interviewer to agree with that statement. After that, the actual balancing feels like a formality. Granted, I still try to get the question right and while I'm writing the code and try to say what I'm thinking...but pointers don't scare me.

@spatula FWIW, I've been writing system software in C for quite some time. So, pointers, concurrency, and other commonly "scary things" that interviewers ask are a daily fact of life for me :)

@jeffpc Yeah, pointers haven't scared me since 1994, but I am very much opposed to wheel reinvention, especially where very tried and true libraries are concerned. The chances of my making some weird corner-case mistake that someone else has already made AND fixed in their library are quite high.

It's all stuff I certainly CAN deal with, but it's not the class of problem I generally NEED to solve, especially when someone else already has done so on my behalf.

@spatula I'm still trying to figure out a good set of questions to ask during an interview. It's essentially impossible to ask about anything actually practical to the company (especially if the sw is proprietary) and toy problems can be easily pointless or insulting. As an interviewer, I've gotten burned once by not doing a thorough enough "coding ability" check. I do not wish to relive the headaches that resulted from it.

@jeffpc My workaround to this problem has been to leave the coding questions to other people and do more abstract interviews instead. One of my favorite things to do in an interview is to find some technology referenced on the candidates resume that I know nothing about myself, and ask them to explain it to me. It tells me a hell of a lot about a person.

Long ago, I used to like to ask people to randomize a list without repeating any values. Bonus points for knowing abt Collections.shuffle().

@jeffpc @spatula @halfogre Git's an incredible tool but it has the unfortunate feature of having some of the absolute worst human interfaces ever. It's an interface only a mad genius programmer with god awful social skills like Linus Torvalds could conceive :)

Because of Linux, and then Github, it gained a massive market adoption advantage.

One day, either Git will evolve to have a better human interface, or be replaced by something better. Until then, I'm glad that you're at least walking the walk and running Mercurial at home. A whole lot of people seem to just like to belly ache :)

@feoh The same thing can be said of that godawful turd of `systemd`. Yet another powerfully capable system with an absolutely bonkers and moronic user interface.

But somewhat puzzling is how they wanted to break apart `initd` which had become such a horrid monolith, and in its place, they erected an even BIGGER monolith, except with modules.

As a developer and CS person, I of course CAN work with obtuse systems like these, but that doesn't make it any less annoying to have to do so.

@spatula @feoh Hehe. I haven't looked at systemd as a monolith replacement for the previous "monolith". Way to go, systemd, way to go. ๐Ÿคฆ

I resisted systemd when it first appeared, and then I ended up ditching Linux completely (first for illumos and then for FreeBSD). :D

@spatula The other big criticism I hear from my crusty old sysadmin friends is that it violates long held contracts that the old school init system used to obey.

Please don't ask me for details, I'd need to invest time in dredging them up :)