top 50 comments

sorted by: hot top controversial new old
[–] 90 points 2 years ago (3 children)

So you're going to git gud?

  • source
  • hideshow 3 child comments
  • [–] 71 points 2 years ago (2 children)

    if u ever get a tricky merge conflict, just git push --force. this automatically works out the right code to keep (your own)

  • source
  • hideshow 2 child comments
  • [–] 65 points 2 years ago

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

  • source
  • [–] 55 points 2 years ago (3 children)
    1. git pull
    2. git reset --hard HEAD
    3. try not to cry
    4. cry a lot
  • source
  • hideshow 3 child comments
  • [–] 17 points 2 years ago (2 children)

    git reflog, you can get your old commits back

  • source
  • parent
  • hideshow 2 child comments
  • [–] 36 points 2 years ago (3 children)

    lemme rebase the main branch onto my branch.

    two minutes later

    1 merge conflict of 57 [abort] [continue]

  • source
  • hideshow 3 child comments
  • [–] 7 points 2 years ago

    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.

  • source
  • parent
  • [–] 29 points 2 years ago

    Pro tip: If your code gets flogged by git, you can always get revenge with git reflog 😉

  • source
  • [–] 26 points 2 years ago (8 children)

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

  • source
  • hideshow 8 child comments
  • load more comments (7 replies)
    [–] 21 points 2 years ago* (7 children)

    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.

  • source
  • hideshow 7 child comments
  • [–] 17 points 2 years ago (5 children)

    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.

  • source
  • parent
  • hideshow 5 child comments
  • [–] 9 points 2 years ago (1 child)

    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.

  • source
  • parent
  • hideshow 1 child comment
  • load more comments (1 reply)
  • load more comments (3 replies)
  • load more comments (1 reply)
    [–] 20 points 2 years ago (2 children)
    load more comments (2 replies)
    [–] 17 points 2 years ago* (1 child)

    This has been the best git tutorial I’ve come across so far. Nicely interactive and gamified. https://learngitbranching.js.org/

  • source
  • hideshow 1 child comment
  • load more comments (1 reply)
    [–] 16 points 2 years ago
    [–] 12 points 2 years ago

    ...not by choice, because if I don't I'll lose my job

  • source
  • [–] 12 points 2 years ago*

    Just rebase your life already

  • source
  • [–] 12 points 2 years ago* (last edited 2 years ago) (4 children)

    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.

  • source
  • hideshow 4 child comments
  • load more comments (4 replies)
    [+] 11 points 2 years ago (9 children)
  • [–] 5 points 2 years ago

    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.

  • source
  • parent
  • load more comments (3 replies)
    [–] 10 points 2 years ago (1 child)

    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.

  • source
  • hideshow 1 child comment
  • load more comments (1 reply)
    [–] 8 points 2 years ago

    When we switched from svn, we had to figure out git with submodules.. that was fun

  • source
  • [–] 6 points 2 years ago (4 children)

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

  • source
  • hideshow 4 child comments
  • load more comments (2 replies)
    [–] 5 points 2 years ago (10 children)

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

  • source
  • hideshow 10 child comments
  • [–] 28 points 2 years ago (3 children)

    Solving merge conflicts or rebasing is not simple

  • source
  • parent
  • hideshow 3 child comments
  • load more comments (1 reply)
  • [–] 13 points 2 years ago*

    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.

  • source
  • parent
  • load more comments (2 replies)
    [+] 5 points 2 years ago* (last edited 2 years ago) (1 child)
  • load more comments
    view more: next ›