Skip to content

Instantly share code, notes, and snippets.

@joladev
Last active August 29, 2015 14:25
Show Gist options
  • Save joladev/f90eea132a6237f65cb8 to your computer and use it in GitHub Desktop.
Save joladev/f90eea132a6237f65cb8 to your computer and use it in GitHub Desktop.
Git 101

Git 101

Some good resources:

Commits

A commit contains a diff of changes, a commit message (which consists of a title and an optional description), a checksum (which is essentially an ID), and a reference to the commit that precedes it. This way, all the commits form a chain you can follow back to the original. Git's history can only go in one direction, this is important to note when you do more advanced stuff with eg git rebase.

Branches

What is a branch? A branch is a reference to a specific commit. As described above, each commit tracks the previous commit, forming long chains of data packets, diffs, that together can be reassembled into data. Every time you make a new commit, the branch starts pointing at this new commit, and the commit remembers the previous one. Although a commit history can be modified and revised, doing this with commits that have been pushed to other repos is dangerous and leads to history conflicts.

You can easily create and throw away branches. Branching takes milliseconds and switching between branches the same.

Comparison to TFS

  • Git is, unlike TFS or svn, a decentralized version control system.
  • Branches are much more lightweight, compared to TFS, and used in a different way.
  • Many possible workflows, eg merge vs rebase.

In TFS, multiple people working on the same branch can get hairy fast. Not so much in git. But most git resources recommend making a lot of branches.

The amazing things that Git does

  • rebase -i
  • cherry-pick
  • add -p
  • diff --stat
  • stash
  • bisect
  • tag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment