this post was submitted on 17 Apr 2024
475 points (98.0% liked)

Linux

47509 readers
1817 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
475
submitted 5 months ago* (last edited 5 months ago) by [email protected] to c/[email protected]
top 37 comments
sorted by: hot top controversial new old
[–] [email protected] 39 points 5 months ago (1 children)

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.

[–] [email protected] 30 points 5 months ago (1 children)
[–] [email protected] 5 points 5 months ago

Looking great. Thanks.

[–] [email protected] 24 points 5 months ago (2 children)

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.

[–] [email protected] 8 points 5 months ago (1 children)

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)%<(16,trunc)%an  %C(auto)%d %>|(1)%s'\'' --all'

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

[–] [email protected] 3 points 5 months ago* (last edited 5 months ago)

Nobody loves pedantic escaped single quoting more than I.

Except for you wow.

Show us the rc.

[–] [email protected] 7 points 5 months ago (1 children)

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.

[–] [email protected] 14 points 5 months ago (1 children)

The technical term is binary search.

[–] [email protected] 2 points 5 months ago (1 children)

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

[–] [email protected] 3 points 5 months ago

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

[–] [email protected] 19 points 5 months ago (1 children)

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.

[–] [email protected] 6 points 5 months ago (1 children)

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

[–] [email protected] 3 points 5 months ago (1 children)

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

[–] [email protected] 5 points 5 months ago (1 children)
[–] [email protected] 17 points 5 months ago* (last edited 5 months ago) (1 children)

Still low quality.

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

[–] [email protected] 6 points 5 months ago
[–] NegativeLookBehind 14 points 5 months ago (1 children)

Gits motto should be “fuck around and find out”

[–] very_well_lost 11 points 5 months ago (2 children)

More like "don't fuck around but find out anyway".

[–] NegativeLookBehind 16 points 5 months ago (1 children)

"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"

[–] [email protected] 3 points 5 months ago

That's what the reflog is for!

[–] [email protected] 1 points 5 months ago

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”.

[–] [email protected] 13 points 5 months ago (1 children)

tl;dr

git add .
git commit -a
git push
[–] Benaaasaaas 4 points 5 months ago (1 children)
[–] [email protected] 1 points 5 months ago* (last edited 5 months ago) (1 children)

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 1 points 5 months ago

I thought -a is shorthand to amend my bad

[–] [email protected] 9 points 5 months ago (2 children)

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)
[–] [email protected] 6 points 5 months ago

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: https://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.

[–] [email protected] 3 points 5 months ago

commit to other branch

'cherrypick'

[–] [email protected] 7 points 5 months ago (1 children)

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

[–] model_tar_gz 4 points 5 months ago (1 children)
[–] [email protected] 2 points 5 months ago (1 children)

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

[–] model_tar_gz 4 points 5 months ago

Some people use git to flog, though. See

git blame
[–] [email protected] 5 points 5 months ago (1 children)
[–] [email protected] 1 points 5 months ago

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

[–] [email protected] 4 points 5 months ago

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

[–] Valmond 2 points 5 months ago* (last edited 5 months ago)

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