pleroma.debian.social

a git cheat sheet

@b0rk maybe it's just me, but somehow I missed a short mention of "git diff" or a pointer to the "diff staged/unstaged changes" section in "know where you are" (or maybe in "prepare to commit"?), as that will show you what you are about to commit – which is usually what I really want to do to prevent doing something stupid. But as I said, maybe that's just me.

[Edit: or maybe move the "diff staged/unstaged changes" between "know where you are" and "prepare to commit"?]

really appreciated everyone's suggestions on the previous thread! https://social.jvns.ca/@b0rk/112276852440106066

I only included things that I actually do in the cheat sheet (with a couple of exceptions like `git push -u`, which I only don't use because I have `push.autoSetupRemote true` configured) but there are a lot of other useful-looking tips in that thread that I don't personally use

the only other things in this cheat sheet that I personally don't use are `git switch` and `git restore`, which I actually think seem like great choices (the fact that `git checkout THING` just GUESSES if you want to switch to a branch or restore an old version of the file is kind of scary! git switch doesn't do that! and git checkout's syntax is just really weird!), but I'm used to `git checkout` and it doesn't cause me a lot of problems so I haven't been motivated to change my ways

@b0rk Sorry if this is already covered and I'm being obtuse, but if there a link to a text version of this somewhere? (I'm only asking because it seems useful for accessibility.)

Another slightly weird but related question: This seems useful and I'd like to post it somewhere at work. Other than crediting you by name, is there other information that should accompany it (a link, a license, or anything)? (And obviously if you object to reposting please say so.)

@internic you can link to https://wizardzines.com for now! there will be a text version eventually

@b0rk I started looking for this poster on your website, and at least I found the bingo card.

https://wizardzines.com/comics/git-discussion-bingo/

@foolishowl here's a link, I'm not totally confident that it'll print correctly though so I'm not sharing it widely yet https://wizardzines.com/git-cheat-sheet.pdf

@b0rk Am-I blind or is `git bisect` missing (I would have expected to find it in the archeology section)? Other than that it's a fantastic cheat sheet.

@robinm i don’t really use bisect so i left it out

@b0rk geat sheet, giteat sheet

@b0rk
After using git for over 15 years, I still find useful things to learn about it (git log -S).

Thanks!
@jpmens
replies
0
announces
1
likes
2

@b0rk Would you mind adding "git add -u" to put in the staged area all modified tracked files?

@b0rk for bringing a branch up to date with another, is there any difference between:

`git merge banana`

and

`git rebase banana`

because I've been doing the latter all this time to keep my local feature branch up to date with the main branch.

@conatus i’m not sure! I think the results are probably the same if it’s a fast forward but I’m not 100% confident of that because the way they work is so different.

personally the reason i would use a merge to fast forward is that if something unwanted happens, i’m sure that I’d find out (because it would create a merge commit). With a rebase i’m not sure.

@b0rk One of my best friends who doesn't work in tech just asked if I could help them better understand git, and I immediately thought of this post. Thank you!! 💖

@pmbrent I hope it helps!