We all have been there… For the beginner it’s easy to mess things up. What are your horror stories with Git?

Link to xkcd

  • @mookulator
    link
    English
    3
    edit-2
    1 year ago

    It’s ridiculous isn’t it? You shouldn’t have to feel like you’re learning some cryptic new language to use version control software.

    Just do a really simple work flow:

    1. “Clone” the code repository from the internet onto your computer (“clone” = “copy”). You only do this once.
    2. Edit code like normal
    3. When you feel happy with some changes you’ve made, “commit” them (“commit” = “save”)
    4. When you’ve committed a few changes, “push” them back to the original repository so your coworkers can see your changes (“push” = “publish”) Repeat

    There are a few good practices:

    • “Pull” often. I.e. update your local copy of the repository with your coworkers’ changes
    • Write an intelligible message with every commit so you and your coworkers can understand what you changed
    • If you’re going to take on a big project, make a “branch” and work there. A branch is like a copy within a copy of the repository so you don’t mess with code that’s already working. When you’re happy with a bunch of commits/pushes in a branch, you “merge” it back into the main repository.

    Everything else is just details!