a git cheat sheet - Julia Evans (cdn.masto.host)
from lemmyreader@lemmy.ml to linux@lemmy.ml on 17 Apr 2024 20:40
https://lemmy.ml/post/14581349

cross-posted from: lemmy.ml/post/14581344

social.jvns.ca/@b0rk/112288027169476498

#linux

threaded - newest

stepanzak@iusearchlinux.fyi on 17 Apr 2024 21:15 next collapse

Great cheat sheet, but has a really poor quality, even when I download it. It may be problem on my side. The original on mastonon has good image quality.

lemmyreader@lemmy.ml on 17 Apr 2024 21:19 next collapse

I’ve edited this post and linked to the original on Mastodon.

saigot@lemmy.ca on 17 Apr 2024 21:41 collapse

ccan you link the higher wuality one here in a comment, I don’t think It’s propagated.

lemmyreader@lemmy.ml on 17 Apr 2024 21:43 collapse

<img alt="" src="https://lemmy.ml/pictrs/image/3791b43d-dbdb-4647-9306-46d27cc7a131.png">

cdn.masto.host/…/8cdf198fa52700f6.png

moe93@lemmy.ml on 17 Apr 2024 21:49 collapse

Still low quality.

EDIT: here is a link to a higher resolution. Link

lemmyreader@lemmy.ml on 17 Apr 2024 21:52 collapse

Thanks!

blobjim@hexbear.net on 18 Apr 2024 05:09 collapse

You have to expand the image to its full size. Thumbnail images are downscaled so they use less data.

NegativeLookBehind@lemmy.world on 17 Apr 2024 20:50 next collapse

Gits motto should be “fuck around and find out”

very_well_lost@lemmy.world on 17 Apr 2024 22:06 collapse

More like “don’t fuck around but find out anyway”.

NegativeLookBehind@lemmy.world on 17 Apr 2024 22:08 next collapse

“Fuck around, have no idea HOW you fucked around, fuck around some more trying to fix it, find out how badly you’ve collectively fucked around”

stsquad@lemmy.ml on 18 Apr 2024 03:02 collapse

That’s what the reflog is for!

lars@lemmy.sdf.org on 18 Apr 2024 19:55 collapse

More like “don’t fuck around (but of course the answer is some subset of git checkout (which is probably Turing-fucking-complete)), and find out anyway”.

boredsquirrel@slrpnk.net on 17 Apr 2024 22:05 next collapse

The only stuff I need, that should be easier

  • commit all changes
  • commit to other branch
  • squash all commits to one
  • configure a ssh key per user (especially when using different accounts, different username etc)
catloaf@lemm.ee on 18 Apr 2024 01:33 next collapse

Commit -a isn’t easy?

Squashing is easy too, though no, there isn’t a “squash all” option, unless you’re working in a feature branch and check out master and git merge --squash branch: graphite.dev/guides/git-merge-squash

I’m sure there’s a way to commit to another branch without having it checked out, but that just sounds like a recipe for trouble.

And I have no idea how you’d manage to not have different ssh keys per user. You shouldn’t be reusing keys across accounts to begin with.

atzanteol@sh.itjust.works on 18 Apr 2024 03:49 collapse

commit to other branch

‘cherrypick’

saigot@lemmy.ca on 17 Apr 2024 23:39 next collapse

I like this graphic, some of my favourites:

git log --oneline is super useful for getting just a list of title of commits and nothing else

git bisect is a little known but extremely useful git archaeology command that automates binary searching for a regression.

caseyweederman@lemmy.ca on 18 Apr 2024 00:02 next collapse

I just learned git bisect from https://ohmygit.org/! You run it, then checkout other commits all over the project, and mark them with git bisect good or git bisect bad. Then it paints all commits that led to the good one as good, and all the ones after the bad one as bad, so you just keep narrowing your window by playing checkout Jezzball until there’s only one commit left: the one that introduced the bad state.

catloaf@lemm.ee on 18 Apr 2024 01:27 collapse

The technical term is binary search.

caseyweederman@lemmy.ca on 18 Apr 2024 01:35 collapse

Yeah but I didn’t know that term until I looked it up. Also OhMyGit didn’t cover using tests and automating it.

huginn@feddit.it on 18 Apr 2024 08:27 collapse

Definitely a useful tool and one you should’ve learned in a college algorithms course. Binary search backs a lot of high performance data structures

fmstrat@lemmy.nowsci.com on 18 Apr 2024 11:36 collapse

You’re gonna love this then:

alias gl='git log --graph --abbrev-commit --no-decorate --date=format:'\''%Y-%m-%d %H:%M:%S'\'' --format=format:'\''%C(8)%>|(16)%h  %C(7)%ad  %C(8)%&lt;(16,trunc)%an  %C(auto)%d %>|(1)%s'\'' --all'

I have a whole rc file full of shortcuts like this for Git and Docker.

lars@lemmy.sdf.org on 18 Apr 2024 19:51 collapse

Nobody loves pedantic escaped single quoting more than I.

Except for you wow.

Show us the rc.

aport@programming.dev on 18 Apr 2024 00:23 next collapse

Reminder to read the official git book. It’s free and it’s useful. My dudes, stop pretending to understand your tools and actually learn them.

catloaf@lemm.ee on 18 Apr 2024 01:27 next collapse
drwho@beehaw.org on 18 Apr 2024 16:57 collapse

Madness!

beeng@discuss.tchncs.de on 18 Apr 2024 09:06 next collapse

LazyGit

For the lazy…

Fedop@slrpnk.net on 19 Apr 2024 04:50 collapse

Love lazygit, am I better or worse a git now? Idk but I’m doing it much faster

Dirk@lemmy.ml on 18 Apr 2024 10:02 next collapse

tl;dr

git add .
git commit -a
git push
Benaaasaaas@lemmy.world on 18 Apr 2024 17:21 collapse

You dropped –force

xthexder@l.sw0.com on 18 Apr 2024 20:11 collapse

Unless you’re rebasing or something, you should never need –force. It’s a good way to accidentally delete or overwrite a remote branch.

I usually use the +syntax for force-pushing a specific branch: git push origin +my_branch

Benaaasaaas@lemmy.world on 18 Apr 2024 21:43 collapse

I thought -a is shorthand to amend my bad

ulterno@lemmy.kde.social on 18 Apr 2024 15:39 next collapse

<img alt="For those who like what I like" src="https://lemmy.kde.social/pictrs/image/25708dce-cb4b-4b0b-83d7-c7a90d171240.png">

lemmyreader@lemmy.ml on 18 Apr 2024 15:54 collapse

Looking great. Thanks.

ulterno@lemmy.kde.social on 18 Apr 2024 16:13 next collapse

Is there anyone other than me who read reflog as re-flog the first time?

model_tar_gz@lemmy.world on 18 Apr 2024 17:02 collapse

Every time.

ulterno@lemmy.kde.social on 18 Apr 2024 17:07 collapse

Always need to remind myself that git doesn’t go around flogging anyone.

model_tar_gz@lemmy.world on 18 Apr 2024 17:42 collapse

Some people use git to flog, though. See

git blame
toastal@lemmy.ml on 18 Apr 2024 16:36 next collapse

Tangent are these VCS Rosetta Stones that might be interesting to some:

Valmond@lemmy.world on 18 Apr 2024 16:20 collapse

I always forget how to do the delete distant branch with the : IIRC.