YⓄ乙
link
fedilink
English
1110M

Lol what’s git?

It’s the thing you use to create a local copy of the main code base, and then merge your changes back in.

OP hasn’t done anything, and there’s 7 conflicts between his code and main. Presumably because someone else merged their changes in the time between when OP pulled his local copy and tried to push his (non-existent) changes.

@EpicFailGuy@lemmy.world
link
fedilink
English
510M

is what people who don’t know vim and rsync have to use to mimic 1% of our power

@kaffiene@lemmy.world
link
fedilink
English
410M

I just did myself an eye injury due to rolling them so much

deleted by creator

@NaoPb@eviltoast.org
link
fedilink
English
1310M

It’s what americans from a rural area say when they want you to go away.

A very complicated way to do

My project
My project (1)
My project WORKING
My project (2)
My project (2) (1)
YⓄ乙
link
fedilink
English
310M

Lol

git gud. HA, GOTTEM

If you can’t use git I don’t see how you’re gonna do with other things. It’s dead simple.

oce 🐆
link
fedilink
13
edit-2
10M

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.

deleted by creator

space_comrade [he/him]
link
fedilink
English
13
edit-2
10M

It’s not THAT complicated but I wouldn’t call it dead simple. When you understand how git works internally yeah it’s pretty simple but people usually start with the idea that it’s a tool to put your code on a server to synchronize with other people and only later learn that you have both a local and a remote (or multiple remote) tree and how the tree really works.

I think the problem is most git 101 tutorials teach it wrong, IMO the best git tutorial is this: https://wildlyinaccurate.com/a-hackers-guide-to-git/

Unfortunately it’s pretty dense so it’s gonna scare off a lot of newbies.

fox [comrade/them]
link
fedilink
English
110M

It’s definitely not simple to use but I agree that the conceptual model it represents is straightforward. I think a lot of the problems people have with git come from not understanding the underlying data structure before learning how to manipulate it.

@sajran@lemmy.ml
link
fedilink
English
510M

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.

Shinji_Ikari [he/him]
link
fedilink
English
110M

Its not dead simple but its also not extremely complex.

I’m currently working with some interns and there’s just concepts they were never exposed to. Without decent mentoring, git can be difficult because a lot of the workflow does come with experience.

That being said everyone needs to stop acting like its an impossible task to properly do source control. There is some truth that if you don’t care enough to do your source control, you don’t care enough to write decent code. Its not a moral failing, just take some pride in your craft.

Show the newbies how to care and they’ll care enough to want to do it right. Measure twice, cut once and all that.

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

The 3-way merge editor in VSCode is a fantastic tool. Really helps in visualizing what comes from where and preventing merge accidents.

It’s doable once you know what you’re doing. I can do it all via the cli, but I personally use gitkraken most of the time and it’s just so much easier and more ergonomic.

I also see a lot of the Devs who insist they know what they’re doing create horrible messes of their branches super easily via the commit tree. People should just use whatever works best for them to get the job done.

Ensign Rick
link
fedilink
English
410M

So many orphaned branches… Poor things.

I prefer rebasing on destination branch before merging. When merging you get all the conflicts at the same time. When rebasing you can address conflicts from one commit at a time. Untangling multiple small knots is easier than one huge spaghetti. Also commit history will be much cleaner.

Shhalahr
link
fedilink
310M

Go, Team Rebase!

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.

katy ✨
link
fedilink
3510M

lemme rebase the main branch onto my branch.

two minutes later

1 merge conflict of 57 [abort] [continue]

kamen
link
fedilink
710M

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.

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!

Andrew
link
fedilink
2010M

Literally.

@PeWu@lemmy.ml
link
fedilink
210M

Oh, you haven’t seen my lack of skill then.

Andrew
link
fedilink
110M

Show me.

So you’re going to git gud?

ditty
link
fedilink
110M

deleted by creator

brothershamus
link
fedilink
3810M

git out

Learning git is very easy. For example, to do it on Debain, one simply needs to run, sudo apt install lazygit

Bipta
link
fedilink
310M

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

corytheboyd
link
fedilink
10
edit-2
10M

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.

Kata1yst
link
fedilink
2510M

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?’

@jcg@halubilo.social
link
fedilink
1
edit-2
10M

I’d still probably prefer the usual CLI for setup, commits, pushes etc. but this looks like a godsend for any branching/rebasing operations!

@lily33@lemm.ee
link
fedilink
1
edit-2
10M

The ease with which I can only commit separate hunks with lazygit has ensured I use it for commits, too. And once I’ve opened it to do the commit, I may as well also press P.

Alex
link
fedilink
110M

Is this what people who haven’t been introduced to #magit use?

Never tried magit, but it doesn’t matter. It couldn’t possibly be good enough to be worth using an inferior editor.

Haus
link
fedilink
610M

sccs, rcs, cvs… after that it’s a blur of new systems every year or two

@kautau@lemmy.world
link
fedilink
13
edit-2
10M

sccs

1973

rcs

1982

git

2005

How long are your years?

Maybe they’re born on a leap year…

And a dog?

pelya
link
fedilink
310M

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.

@wewbull@feddit.uk
link
fedilink
English
210M

I’d agree if anyone actually used the distributed nature of DVCS

…not by choice, because if I don’t I’ll lose my job

@erogenouswarzone@lemmy.ml
link
fedilink
English
12
edit-2
10M

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.

deleted by creator

I hear what you’re saying.

First, I hard disagree with you. Overwriting my local version of code is a parachute - not an ideal landing, but better than merging by hand.

Also, my comment was not an attempt to teach everything about git, just to explain what is happening in simple terms, since git requires a lot of experience to understand what those messages mean.

If I get a big conflict and I know my change is trivial, I feel perfectly okay doing git fetch git reset --hard whatever and then reapplying my simple change as a new commit. Sort of a bootleg rebate.

If you use a squash workflow, you’re going to be force pushing a ton.

Never force git to do anything. If you’re forcing something you’re doing it wrong.

This is bad advice. Better advice would be “know and understand your tool, and know the consequences of your actions”.

@lolcatnip@reddthat.com
link
fedilink
English
110M

I swear to God sometimes git just conjures merge conflicts out of nothing.

Highly recommend bookmarking https://ohshitgit.com, it’ll steer you right 👍

Create a post

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.
  • 1 user online
  • 120 users / day
  • 257 users / week
  • 744 users / month
  • 3.72K users / 6 months
  • 1 subscriber
  • 1.47K Posts
  • 32.3K Comments
  • Modlog