Live data from Hacker News

Git Branches: Intuition and Reality

jvns.ca

1–10 of 281 posts

Re: Git Branches: Intuition and Reality

#4
post #3

I cannot be the only one that gets away with only knowing: git pull git merge x git checkout [-b] foo git commit git push

Possibly `git branch NEWBRANCHNAME` instead of `git checkout -b NEWBRANCHNAME`. When I need to show git to someone in order for them to contribute to something, I give them only these incantations --- and instructions to ask me if weird git things happen.

Re: Git Branches: Intuition and Reality

#6
post #3

I cannot be the only one that gets away with only knowing: git pull git merge x git checkout [-b] foo git commit git push

FWIW that's 99% of my usage of git

(well... it's about 1% because I do everything using the eclipse git UI, but that's the same behavior you get from that commands)

Re: Git Branches: Intuition and Reality

#8
A lot of things in git are just pointers to commits, and then the git implementation handles them under the covers in some way that usually makes sense but not always.

One example that also bites people: moving files isn't stored in git - if you move files (even with `git mv`) and create a new commit, the moves aren't stored, but this is reconstructed later by the client based on similarity, which comes from the diff algorithm.

And git has multiple diff algorithms to pick from: https://git-scm.com/docs/git-config#Documentation/git-config...

And optionally to not detect renames in diff output with `diff.renames`: https://git-scm.com/docs/git-config#Documentation/git-config...

Re: Git Branches: Intuition and Reality

#10
post #3

I cannot be the only one that gets away with only knowing: git pull git merge x git checkout [-b] foo git commit git push

protip: If you want to switch branch you can now use "git switch [-c] foo". If you want to restore files you can do "git restore .".

Basically you can stop using checkout.

*edit*: fixed switch branch creation parameter.

Post reply on HN