Live data from Hacker News

ToolGit: A collection of scripts that extend Git with various sub-commands

github.com

31–40 of 59 posts

Re: ToolGit: A collection of scripts that extend Git with various sub-commands

#31
post #14

These should be aliases in your git config. git config --global alias. I'm really trying to understand, and not to be too negative. I get coming up with a solution to a problem, and finding it neat locally. But before posting to HN, one might realize that these solutions that git provides existing tools for is better than maintaining this. I'm also confused by all the comments just blindly commenting in the affirmati…

The trouble is that git aliases aren't composable and you can't install them. Each installation has its own aliases. If you are in a new machine you must define the aliases yourself. This also makes git aliases have poor discoverability. Compare this with another tool that lets people extend its own command, cargo. You can do cargo install and then run cargo .

As a culture we need to move away from “just write these things yourself/copy these aliases and maintain them”. It makes things too much of a rite of passage.

No, I have never used NPM directly. Why do you ask?

Re: ToolGit: A collection of scripts that extend Git with various sub-commands

#32
post #14

These should be aliases in your git config. git config --global alias. I'm really trying to understand, and not to be too negative. I get coming up with a solution to a problem, and finding it neat locally. But before posting to HN, one might realize that these solutions that git provides existing tools for is better than maintaining this. I'm also confused by all the comments just blindly commenting in the affirmati…

Hi! Author here. Some of these can indeed be an alias, others.. not so much. `git-root` for example is more-or-less a one-liner, meanwhile `git-mode-restore` is a ~840 loc python script. I do use git aliases but trying to do anything non-trivial in them seems rather counter-productive so I'm confused about everyone suggesting it :P

It seems to me like a shallow reading and dismissal of your work. Which is sad. For what it's worth I'll be giving it a go as soon as I'm back at work on Tuesday.

Re: ToolGit: A collection of scripts that extend Git with various sub-commands

#33

https://gist.github.com/romainl/a3ddb1d08764b93183260f8cdf0f... This script in your path means that after you say pull code and have merge conflicts, "git jump" will open vim with the quickfix list populated with the locations of the conflicts.

How’s this different to ‘git mergetool’?

Re: ToolGit: A collection of scripts that extend Git with various sub-commands

#34
post #7

Obligatory mention of https://github.com/tj/git-extras/blob/main/Commands.md for more/similar commands. Especially useful to me is `git bulk` to apply a command to all the git repos under the directory, and `git ignore "bin/"` to quickly add something to the `.gitignore` file.

I like these a lot! It seems like git-extras is pure bash allowing it to work out of the box without any dependencies but I would probably go mad if I had to implement¹ reading/writing git index² in bash.

¹ https://github.com/ahmetsait/toolgit/blob/58713ead5abc060510...

² https://git-scm.com/docs/index-format

Re: ToolGit: A collection of scripts that extend Git with various sub-commands

#35
post #24
post #14

These should be aliases in your git config. git config --global alias. I'm really trying to understand, and not to be too negative. I get coming up with a solution to a problem, and finding it neat locally. But before posting to HN, one might realize that these solutions that git provides existing tools for is better than maintaining this. I'm also confused by all the comments just blindly commenting in the affirmati…

What would the alias command be for git-delete-gone-branches ? EDIT: I saw your other comment (incorrectly) claiming that git remote prune origin will do the job. I don't know of any git trickery that can do the job. And believe me I'd love it if there was something.

Thanks for keeping me honest. I just read the first line of the stackoverflow, but the one liner is still in the comments. I just tested it.

https://stackoverflow.com/questions/7726949/remove-tracking-...

    git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -d

Re: ToolGit: A collection of scripts that extend Git with various sub-commands

#36
post #25
post #12

Earlier quoted context omitted.

"git delete gone branches" is a one liner that you can google. first stack overflow result gives you the answer: git remote prune origin Why would you use this 50 line script to do the same?

This only removes references to remote branches. See e.g. [0]. The command in OP operates on local branches. [0] https://stackoverflow.com/questions/20106712/what-are-the-di...

Just for anyone else following along..you're right. Here it is.

    git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -d

Re: ToolGit: A collection of scripts that extend Git with various sub-commands

#37
post #14

These should be aliases in your git config. git config --global alias. I'm really trying to understand, and not to be too negative. I get coming up with a solution to a problem, and finding it neat locally. But before posting to HN, one might realize that these solutions that git provides existing tools for is better than maintaining this. I'm also confused by all the comments just blindly commenting in the affirmati…

Hi! Author here. Some of these can indeed be an alias, others.. not so much. `git-root` for example is more-or-less a one-liner, meanwhile `git-mode-restore` is a ~840 loc python script. I do use git aliases but trying to do anything non-trivial in them seems rather counter-productive so I'm confused about everyone suggesting it :P

Hey. I think my point is that writing and maintaining 900 lines of code is an option, and another option is to figure out how to not write and rely on 900 lines of code. I looked through git-more-restore a bit and I think you're trying to reverse permission changes in your working branch back to what's on HEAD.

I think a way to do this is to not let git track that in the first place, with some variation of:

    git config core.fileMode false
via: https://stackoverflow.com/questions/1580596/how-do-i-make-gi...

or

https://stackoverflow.com/questions/2517339/how-to-restore-t...

Re: ToolGit: A collection of scripts that extend Git with various sub-commands

#38

Some of my git aliases might be useful to folks here (I post them from time to time on git threads) Time to share my gitconfig aliases again :D lol = !git --no-pager log --graph --decorate --abbrev-commit --all --date=local -25 --pretty=short sw = !git checkout $(git branch -a --format '%(refname:short)' | sed 's~origin/~~' | sort | uniq | fzf) lc = !git rev-parse HEAD rb = !git for-each-ref --sort=-committerdate ref…

I see that you're using --print0 and -0 for your "git fza" alias, it might be useful to add -z to the git-ls-files invocation and --read0 to fzf.

Re: ToolGit: A collection of scripts that extend Git with various sub-commands

#39

Some of my git aliases might be useful to folks here (I post them from time to time on git threads) Time to share my gitconfig aliases again :D lol = !git --no-pager log --graph --decorate --abbrev-commit --all --date=local -25 --pretty=short sw = !git checkout $(git branch -a --format '%(refname:short)' | sed 's~origin/~~' | sort | uniq | fzf) lc = !git rev-parse HEAD rb = !git for-each-ref --sort=-committerdate ref…

I see that you're using --print0 and -0 for your "git fza" alias, it might be useful to add -z to the git-ls-files invocation and --read0 to fzf.

Ah, good point, I do need to revisit these and tidy them up. The perils of cargo-culting!

Re: ToolGit: A collection of scripts that extend Git with various sub-commands

#40
post #35
post #24

Earlier quoted context omitted.

What would the alias command be for git-delete-gone-branches ? EDIT: I saw your other comment (incorrectly) claiming that git remote prune origin will do the job. I don't know of any git trickery that can do the job. And believe me I'd love it if there was something.

Thanks for keeping me honest. I just read the first line of the stackoverflow, but the one liner is still in the comments. I just tested it. https://stackoverflow.com/questions/7726949/remove-tracking-... git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -d

Same as mine. I also pass the `-r` flag to xargs so it doesn't run if there are no inputs.
Post reply on HN