top | item 42035550

(no title)

henshao | 1 year ago

These should be aliases in your git config.

    git config --global alias.<cmd> <cmd>
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 affirmative or providing suggestions. Are we all bots?

discuss

order

mindcrime|1 year ago

But before posting to HN, one might realize that these solutions that git provides existing tools for is better than maintaining this.

One might. But not everybody knows about those existing tools. Taking myself as an example: I've been using Git since nearly the time it was released and I had no idea that git had aliasing built in. Sometimes things just never come up and people don't find out about them. shrug

ahmetsait|1 year ago

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

henshao|1 year ago

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...

n4r9|1 year ago

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.

n4r9|1 year ago

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.

kaffekaka|1 year ago

I have an alias "git prune-branches" that deletes branches that remote has deleted. Is that what you are loking for? Cannot check the code right now but will try to get back tomorrow.

nextaccountic|1 year ago

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 <something> and then run cargo <something>.

keybored|1 year ago

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?

bloopernova|1 year ago

If I see a git thread, I tend to semi-spam my git aliases because so few people realize that they can customize git's command line behaviour.

henshao|1 year ago

Yeah I am just finding it hard to believe that there are so many people who don't.

Maybe we are 10x engineers w.r.t. git aliases. Congratulations

cowsandmilk|1 year ago

You’re suggesting not to use a functionality built into got from early days that naming a script git-something and putting it on your PATH gives you a sub command of “git something”.

Why do you disagree with this early decision from git?

parentheses|1 year ago

Came here to say this.

I looked at 1/3 of the scripts and not one _adds_ functionality, they only add interfaces for existing functionality.

I hate to say this but I feel like this post got upvoted simply for being hit-adjacent.

I wonder if voting on the front page is a bad setup.