Live data from Hacker News

Lesser known Git commands

hackernoon.com

1–10 of 142 posts

Re: Lesser known Git commands

#4
I like the `git grog` command, I might actually use that.

The idea of `git please` is not bad but it made me wonder if it could be possible to go even further.. a variant on --force that only force-pushes IF NOT ONE HAS PULLED YET.

I can see why this wouldn't be built into git core however, as it's quite stateful and depends on tracking other people's fetches, which probably isn't easy.

Re: Lesser known Git commands

#5
post #2

Warning: not actually git commands, rather TFAA's aliases for possibly useful combinations of switches and/or commands.

See, switches in git are there because git maintains backward compatibility. Sometimes a switch really would logically be better as a whole new command. But it's a common refrain to hear that git hides useful things in the switches.

This article is a great way to find those hidden things.

Re: Lesser known Git commands

#6
My personal favorite two:

    jschroeder@omniscience:~$ git config alias.up
    pull --rebase
    jschroeder@omniscience:~$ git config alias.down
    push
They can be used thusly:

   git up && git down

Re: Lesser known Git commands

#7

Some of the aliases are funny but could be renamed for brevity. Also grog is making me feel extremely groggy.

"commend" seems especially bad, it's both unclear and longer than "amend" would be.

My aliases list is pretty small, aside from amend I have

* get (pull --ff-only --all -p), basically a hard sync with all remotes, updating the current branch if there are no conflicts or divergences

* summary (log --oneline --no-merges), given a range from git fetch/pull, provides an overview of the commits you just fetched

* original (!git show $(cat .git/rebase-apply/original-commit)) during a rebase conflict, shows the original commit whose application failed (it can be difficult to untangle a rebase conflict, this sometimes helps a lot)

Re: Lesser known Git commands

#8
Didn't know about those stash options. I've always used 'git stash save -u' to bring along the untracked files in the stash, that's the more common scenario.

Re: Lesser known Git commands

#9
post #5
post #2

Warning: not actually git commands, rather TFAA's aliases for possibly useful combinations of switches and/or commands.

See, switches in git are there because git maintains backward compatibility. Sometimes a switch really would logically be better as a whole new command. But it's a common refrain to hear that git hides useful things in the switches. This article is a great way to find those hidden things.

> See, switches in git are there because git maintains backward compatibility.

Switches are there because git commands tend to greatly leak the abstraction and group behaviour in terms of the underlying plumbing, and because Git maintainers most likely would rather add new switches to existing commands than new commands intersecting with existing ones.

> Sometimes a switch really would logically be better as a whole new command.

Which could trivially be done without BC issues and thus can't be an explanation why existing commands keep growing new switches.

> This article is a great way to find those hidden things.

It would have been a useful article if it had been about showcasing interesting or useful git switches.

Post reply on HN