So you're going to git gud?
Programmer Humor
Post funny things about programming here! (Or just rant about your favourite programming language.)
Rules:
- Posts must be relevant to programming, programmers, or computer science.
- No NSFW content.
- Jokes must be in good taste. No hate speech, bigotry, etc.
if u ever get a tricky merge conflict, just git push --force
. this automatically works out the right code to keep (your own)
Also, a way to never have to work again!
Except if you're an employer in a very small company.
Source: my boss did this at the first company I worked at.
- git pull
- git reset --hard HEAD
- try not to cry
- cry a lot
git reflog, you can get your old commits back
But I want to pretend none of this ever happened.
git can we just pretend the last 30 minutes never happened
I feel like that would get more use than people want to admit.
lemme rebase the main branch onto my branch.
two minutes later
1 merge conflict of 57 [abort] [continue]
this is easily fixed by copy pasting the files into a new directory and never opening git again out of fear
Project managers hate this one weird trick!
One key thing that can help you wrap your head around rebasing is that branches get switched while you're doing it; so, say you're on branch feature
and do git rebase master
, for any merge conflict, whatever's marked "current" will be on master
and what's "incoming" is from feature
.
There's also git rerere
that should in theory remember a resolution you do between two branches and reuse it every time after the first; I've rarely used it in practice; it would happen for long lived branches that don't get merged.
Pro tip: If your code gets flogged by git, you can always get revenge with git reflog
😉
Learning git is very easy. For example, to do it on Debain, one simply needs to run, sudo apt install lazygit
LazyGit may actually be black magic from Satan to tempt programmers into sin. And to that I say: 'where is a goat I can sacrifice to my dark lord?'
Wow this looks great. Amend an old commit dealing with a rebase? Sign me up!
git rebase -i origin/main
(or whatever branch you're rebasing on), then read the instructions that come up in the editor window
Read… instructions? I love teaching people that git very often prints out what you should do next.
git: “to continue, resolve conflicts, add files, and run rebase —continue”
dev: …time to search stack overflow
All that said… just use lazygit. It does help to know CLI git first to put things in context, but if you do, no need to punish yourself every day by not using a UI.
Git is a great invention but it has a few design flaws. There are too many ways to confuse it or break it, using commands that look correct, or just forgetting something. I ended up writing simple wrapper script codebase to fix it. Since then no problems.
It was conceived for experts so the new user experience is shit and the UI is not intuitive. But it has become such a widespread standard that it is very hard to completely overhaul the UI.
TBH compared to the old versioning system people used to use like SVN and Mercurial. Git is a godsend. Just taking your time in learning and not using a GUI client works wonders in learning how it works. Especially when all the GUI clients are basically a collection of commands being executed so if you fuck things up on CLI you know what happened vs using GUI.
Even for experts the user experience is shit. Too much has to be done manually when the default should be automatic, like fetching before pull, recursing when working with repos that use submodules, allowing mismatched casing on case insensitive filesystems, etc.
This has been the best git tutorial I’ve come across so far. Nicely interactive and gamified. https://learngitbranching.js.org/
...not by choice, because if I don't I'll lose my job
Just rebase your life already
Lol what's git?
It's what americans from a rural area say when they want you to go away.
is what people who don't know vim and rsync have to use to mimic 1% of our power
I just did myself an eye injury due to rolling them so much
A very complicated way to do
My project
My project (1)
My project WORKING
My project (2)
My project (2) (1)
Lol
Great meme, and I'm sure op knows this, but for anyone else who is curious...
007 in theory means:
- 00: you have already committed your code to your local code base
- 7: When you try to merge your code with everyone else's there are 7 files that others have worked on since you last refreshed your local code base.
To resolve this, you need to go file by file and compare your changes with the changes on the remote code. You need to keep the changes others have made and incorporate your own.
You can use git diff file_name
to see the differences.
If you have made small changes, it's easier to pull and force an overwrite of your local code and make changes again.
However multiple people working on the same files is usually a sign of organizational issues with management. Ie, typically you don't want multiple people working on the same files at the same time, to avoid stuff like this.
If you're not sure, ask someone that knows what they're doing before you follow any advice on Lemmy.
sccs, rcs, cvs... after that it's a blur of new systems every year or two
sccs
1973
rcs
1982
git
2005
How long are your years?
Maybe they're born on a leap year...
And a dog?
Subversion is as good as it can get with centralized version control system.
CVS is only one step up above FTP file server for all your code.
If you can't use git I don't see how you're gonna do with other things. It's dead simple.
Solving merge conflicts or rebasing is not simple
Do it enough times and it stops being scary.
Using a tool like VSCode to perform the actual merges on individual files also helps because it shows what "yours" and "theirs" changes are from a user perspective, not a git perspective
If it was dead simple you wouldn't need to learn 10 new concepts and google commands regularly even after using it for a couple of years. You probably forgot how you struggled at first. I have taught it multiple times and I see how beginners struggle.
I would actually say it's VERY complicated but in daily work you probably need like 5 commands and those aren't hard at all.
So many orphaned branches... Poor things.
This week? I've been using it for years and I'm still learning it