Hacker News new | ask | show | jobs
by ctxcode 478 days ago
how i've used git every day in the last 10 years:

git add -A, git commit -m, git push

If there's an error because there are changes on the remote, type:

git pull, fix conflicts in case there are any, repeat previous commands

In all other cases, google/grok for the solution, doesnt happen often.

4 comments

Not to be annoying, but maybe one of the most useful things git does for me outside of the usual SCM stuff, is git-bisect. Its saved me many hours of debugging.

If you ever run into a case where something is broken (that you can measure, like a test or broken build) but it’s not obvious what change caused the fault, first go to a commit where you know the fault is present.

    $ git bisect start
    $ git bisect bad
Then go to a commit where you know the fault is NOT present. Go back far if you can! This can be in another branch as long as your start and end spots are connected somehow.

    $ git checkout abc123
    $ git bisect good
And after that bisect command, your HEAD will get moved to the mid point between the good and bad commits. Check if the fault is still there, and run either "git bisect good" or "git bisect bad" depending on if it’s resolved or not.

It will keep jumping you to the mid point between the nearest bad commit and good commit till you end up at 1 precise commit that caused your fault.

This works extremely well for configuration changes specifically, where maybe it doesn’t break in CI, but on your local dev machine it does. You can also use this for non-text files like images to find out when 1 part of an image was changed for example.

Also if you just want to make normal SCM stuff easier,

    $ git commit -Am "…"
For a combo add-everything+commit
Thanks for explaining this so clearly! I'm going to try this next time :)
Thanks for sharing your workflow - nice and simple! And sounds like you've got a rhythm down with those core commands, which I know is the case for many Git users.

One of the things I'm trying to explore with these visual and gamified tools is how to help newer Git folks or even users who mostly live in that commit/push/pull flow get a clearer mental model of what's actually happening under the hood.

Git has a really wide breadth of functionality that is kind of interesting on its own merit, but also useful for a plethora of different tasks. For better or worse even Git experts can always find ways to expand their knowledge :)

haha although I use a bunch of Git commands and am comfy with the internals, I use a similar workflow most of the time.

"commit all files and add a comment" = `cam`, "also push" = `camp`

> cam "fixed bug"

alias cam='git commit -am'

function camp() { git commit -am "$1" git push }

I'm sorry, but it's been ten years and you haven't learned how to handle other git situation? And then you're dependent on Google? Is there a reason why you haven't sat down to learn some more?
Haha yes I am extremely curious to hear the answers to these questions as well to understand the utter stagnation here.