28 votes

Git for Beginners: Zero to Hero

5 comments

  1. jdsalaro
    Link
    Hey everyone ๐Ÿ‘‹๐Ÿผ I wrote a Blogpost that was received well on Reddit but since I'm having a look at alternative platforms I figured I should start by reposting it here, hope you enjoy it and don't...

    Hey everyone ๐Ÿ‘‹๐Ÿผ

    I wrote a Blogpost that was received well on Reddit but since I'm having a look at alternative platforms I figured I should start by reposting it here, hope you enjoy it and don't hesitate to share your feedback ๐Ÿ‘๐Ÿผ

    12 votes
  2. [2]
    bhrgunatha
    Link
    Thanks for sharing and good job. I think it's a good article. I expect beginners would need to review it quite often as their experience grows. I do think that's a good thing though. A beginner...

    Thanks for sharing and good job. I think it's a good article.
    I expect beginners would need to review it quite often as their experience grows. I do think that's a good thing though. A beginner reading the whole article helps them form a good mental model, but will forget, misunderstand or misremember parts of it. They can then review or research further.

    These aren't perfect; everyone has their preference for how to learn. For me two things that helped me tremendously with git:

    • Knowledge is Power: Getting out of trouble by understanding Git by Steve Smith. It explains the internal data structures and objects used by git and builds from the very start of creating a repository using the infamous plumbing commands, and then goes on to explain many, many things about how git actually works. For example exactly what branches and tags are, merging, fast-forward, and even the difference between the infamous rebase and cherry picking.
    • NDP software's interactive Git Cheatsheet. I have no affiliation with them, it's simply one of the best cheatsheets I've ever seen. It clearly shows the different areas of git - stash, workspace, index, local repository and remote repositories. By clicking on each one it shows you a filtered set of commands specific to that area as well as the other areas the command affects. By highlighting a command it shows an example and a short description at the bottom.
    3 votes
    1. jdsalaro
      Link Parent
      Thanks for sharing these two, I just finished reading through them and must say that I enjoyed them :D Playing with the interactive cheatsheet was certainly lots of fun!

      Thanks for sharing these two, I just finished reading through them and must say that I enjoyed them :D Playing with the interactive cheatsheet was certainly lots of fun!

      1 vote
  3. [2]
    stu2b50
    Link
    So, this is strictly speaking, wrong. A commit doesn't contain changes, it contains the entire file at that point in time. When diffs are presented (say, from git diff), it is actually computed on...

    A commit is a group of changes which have been โ€˜savedโ€™ or committed to the local repository by telling git to do so... A commit โ€˜containsโ€™... the changes which were made.

    So, this is strictly speaking, wrong. A commit doesn't contain changes, it contains the entire file at that point in time. When diffs are presented (say, from git diff), it is actually computed on the fly. This distinction does matter.

    Some relevant reading material:

    https://github.blog/2020-12-17-commits-are-snapshots-not-diffs/

    https://www.softwaremeadows.com/posts/git_commit_checkout_is_a_snapshot__not_a_delta/

    I also think it's worthwhile noting, with emphasis, that commits are immutable. Truly immutable. Rebase does not change commits, it makes new commits. If a commit exist, it will always be the same.

    1. jdsalaro
      Link Parent
      @stu2b50, I agree with your statement, that commits don't contain changes but rather the snapshot of the file at point in time. I was expecting the quotes to be sufficient, but I've reworded that...

      @stu2b50, I agree with your statement, that commits don't contain changes but rather the snapshot of the file at point in time. I was expecting the quotes to be sufficient, but I've reworded that sentence to reflect reality a bit better.