Understanding SVN and Git

I admit, my understanding of revision control is quite limited.  So I sat in on David Humphrey’s OSD class to learn more about Git.

SVN:

  • Client server model
  • highly centralized

Workflow

  • checkout – gets the tip of the trunk (most recent revision).  Your local copy  (working copy)
  • commit – sends change set (difference between trunk and your working copy)
  • update – update your working copy with new change set.

RULE: DO NOT BREAK TRUNK

Suppose person A and person B checkout version 351 on the same day.  Person A changes some code and commits it back to trunk. person B will have to update their version (pulls down change set ) and resolve conflicts.

GIT

Distributed version control.  Not centralized model.

  • Clone – similar to checkout BUT, you are making a copy of the entire tree (not just the most recent change
  • Fork – create a split locally
  • Merge – merges a fork back

File states with GIT.  When working with GIT, your files are in one of 3 states:

  1. Committed: – committed to the repository
  2. Staged:  – inbetween state, git is aware of file but its not yet in the repository
  3. Modified: – working copy not in repository

GIT Command summary:

  • git help command <command>
    • tells you how a command works
  • git status
    • gives status of files
  • git add <file>
    • stage a file
  • git commit -m <message>
  • git diff
    • space in front of a line, line is context line to show you where change is
    • + line added
    • – line removed

Ignoring files:

If there are files that you want git to ignore (ie don’t track and don’t tell you its not tracking it) you can create .gitignore. You can add specific files or patterns.  For example:

  • *.o to exclude object files
Advertisements

One response to “Understanding SVN and Git

  1. Hi Cathy, long time no talk

    When I look back at my Seneca days, one of the major regrets I have is not using source revision control on my early course projects. More than once I had to rewrite from memory an entire source file after a mistake delete, and I would have loved to have the “revert” feature as I chased into a false rabbit hole.

    I would suggest to the profs at Seneca to teach source control during week 1 of semester 1, except that I think its important to have the negative experiences of rewriting entire source so that students truly appreciate the features modern source revisioning tools can supply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s