News for hackers. Stuff that matters.
Re:Ask HN: Programs that saved you 100 hours? by jldugger on Sunday April 12, 2020 @11:59PM (#22853063)
For better or worse, I find GUI git clients to be less useful than the CLI. But like any CLI tool, it's productivity is limited by your ability to type without errors. Git has an Autocorrect[1] that will help you out.

> git config --global help.autocorrect 1

Based on bash history data, I've also added a simple alias to my bash config:

> alias gti="git"

[1]: https://git-scm.com/book/en/v2/Customizing-Git-Git-Configura...

Re:Ask HN: Programs that saved you 100 hours? by hiq on Monday April 13, 2020 @02:34AM (#22853646)
"Based on bash history data" is an interesting point, because it highlights that you can use your history to periodically check what you do inefficiently in the terminal, and which aliases you still need to add to your config: compute some statistics on the number of 1-word and 2-word commands you use the most, and see if they are more than e.g. 4 letters.

With zsh: "history 1 | awk '{print $2}' | sort | uniq -c | sort -n"

With bash I think this should be "history" instead of "history 1".

Re:Ask HN: Programs that saved you 100 hours? by m463 on Monday April 13, 2020 @08:10AM (#22855100)
I make one change to every new .bashrc file.

I change this:

  HISTSIZE=1000
  HISTFILESIZE=2000
to:

  HISTSIZE=1000000
  HISTFILESIZE=2000000
You would be surprised how useful this one change has been, answering historical questions easily, like how to generate that rsa key, or what packages did I install for that project last year.

You can usuall answer questions with ^r instead of the man page. Or maybe:

  "history | grep -C 10 <foo>"
Re:Ask HN: Programs that saved you 100 hours? by fragmede on Monday April 13, 2020 @04:18AM (#22854041)
While we’re on the subject of shortcuts, I have `awk1` mapped to `awk '{print $1}'` and the same up to awk9. It’s not that I can’t type it but it breaks my flow for such a simple use case.
Re:Ask HN: Programs that saved you 100 hours? by Siira on Thursday April 16, 2020 @07:30AM (#22888336)
`history 200000 | awk '{print $2" "$3}' | sort | uniq -c | sort -n`
Re:Ask HN: Programs that saved you 100 hours? by williamdclt on Monday April 13, 2020 @07:15AM (#22854794)
There's a section of people that I belong to, that aren't fans of the GUI clients because it doesn't fit in their workflows but also find the CLI not productive enough. We start writing aliases and custom scripts. We integrate git with FZF.

Well for all of these people: I recently found Lazygit (https://github.com/jesseduffield/lazygit) which is a terminal UI for git and that does exactly what I've been looking for all these years, down to vim-like keybindings!

Re:Ask HN: Programs that saved you 100 hours? by gitgud on Monday April 13, 2020 @08:09AM (#22855096)
I think I've used a very similar one called LazyDocker. But after a while I found that it wasn't that useful, and I don't like seeing the "donate" button in my face all day (call me old-fashioned).

The true power of CLI apps comes from "alias" commands that you build up yourself. The following commands are great examples of this:

    alias docker-kill-all='docker kill `docker ps -aq`'
    alias docker-rm-all='docker rm `docker ps -aq`'
After a while I've learnt that a gui or cli-gui can never compose as well as the terminal can...
Re:Ask HN: Programs that saved you 100 hours? by williamdclt on Monday April 13, 2020 @01:44PM (#22858041)
Lazydocker is made by the same guy yes! I don't find it as useful though.

> The true power of CLI apps comes from "alias" commands that you build up yourself

I usually agree. I spent way too many hours making aliases and I'm very proficient at it. But sometimes there's something like lazygit which does everything my aliases did, but slightly better as it gives me, for example, line-by-line staging and vim keybindings.

It is true that it does not compose, but I can still (and do) use the command line. It's just a nice increase of productivity in 90% of the cases (for me!)

Note: I'm not related to the lazygit project in any way, just very satisfied with it

Re:Ask HN: Programs that saved you 100 hours? by iamuser4 on Monday April 13, 2020 @02:26PM (#22858481)
Obligatory emacs magit. If you like the git cli, then magit will help you do everything with single keypress actions (l is log, c is commit) and provide autocomplete and lists where relevant (like all branches on checkout)

https://magit.vc/

Visual walk through: https://emacsair.me/2017/09/01/magit-walk-through/

Re:Ask HN: Programs that saved you 100 hours? by girishso on Monday April 13, 2020 @02:26AM (#22853620)
Better still

> alias g="git"

Re:Ask HN: Programs that saved you 100 hours? by yks on Monday April 13, 2020 @11:36PM (#22862541)
or g = ./gradlew
Re:Ask HN: Programs that saved you 100 hours? by emilburzo on Monday April 13, 2020 @02:36AM (#22853650)
> For better or worse, I find GUI git clients to be less useful than the CLI.

Genuinely interested, why?

I'm a huge fan of the CLI in general, but for some things it just slows me down, git usage is one of those.

Random example: reverting a commit is 2-3 clicks, or a whole lot of typing.

Re:Ask HN: Programs that saved you 100 hours? by jldugger on Monday April 13, 2020 @12:24PM (#22857190)
> Genuinely interested, why?

They usually don't support the level of granularity I have on the CLI. For example, if I want to fix a commit on a PR based on feedback I've received, I can make the fix and `git rebase -i` will let me amend any of my previous commits (via 'fixup'). None of the IDEs I've tried support it; it's possible instead of an IDE one of the dedicated git tools like Kraken support this?

It's also just mildly terrifying when the IDE gives you a button with no further explanation for what it's actually doing. I.e. what do 'refresh' and 'sync' do in VS Code? The consequences could be dire: https://github.com/microsoft/vscode/issues/32405

> reverting a commit is 2-3 clicks, or a whole lot of typing.

Git revert is a single command; finding the commit to revert is the hard part. `git bisect` makes this easy, and I haven't seen any IDEs nail that one. That said, this is a rare use case.

Re:Ask HN: Programs that saved you 100 hours? by ScottFree on Monday April 13, 2020 @07:16AM (#22854797)
> Random example: reverting a commit is 2-3 clicks, or a whole lot of typing.

    git log
    git revert {hash}
I'd hardly call that a whole lot of typing. It's roughly equivalent to 2-3 clicks in a GUI app.

Where the GUI falls down for me is more complicated things, like hard resetting a branch to origin or resolving merge conflicts.

Also, most of the git guis do things that I find distressing. For example, in one git GUI I tried a while back, I accidentally dragged a commit onto a branch listed in the sidebar. Only later did I realize the gui cherry-picked the commit into the branch without asking me for confirmation. It would do similar things if I dragged one branch into another.