Your browser doesn't support the features required by impress.js, so you are presented with a simplified version of this presentation.

For the best experience please use the latest Chrome, Safari or Firefox browser.

Git

Basic Principles

Created by Sankhesh Jhaveri (@sankhesh)

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License.

Why version control??
gitk
Ref:Pro-Git Book local_version_control centralized version control distributed version control
Installation

Linux

$ sudo apt-get install git gitk


Windows
msysgit.github.com


Mac
code.google.com/p/git-osx-installer

Introduce yourself

$ git config --global user.name "Your Name"
$ git config --global user.email youremail@email.com


Check Configuration

$ git config --list


Getting help

$ git help

In a nutshell
Git in a nutshell
SHA-1 sum

$ echo 'Hello, world!' > greeting

$ git hash-object greeting
af5626b4a114abcb82d63db7c8082c3c4756e51b


Cloning an existing repository

$ git clone git://github.com/ASIST-SUNY-Albany/Git-Workshop-2013.git myRepo

$ git clone https://github.com/ASIST-SUNY-Albany/Git-Workshop-2013.git myRepo

$ git clone git@github.com:ASIST-SUNY-Albany/Git-Workshop-2013.git myRepo

Undoing things
Amend Last commit

$ git commit --amend


Unstaging a staged file

$ git reset HEAD filename


Unmodifying a modified file

$ git checkout -- filename

Ref:Pro-Git Book Blame

$ git blame filename


git blame
Ref:Pro-Git Book Branching

$ git checkout -b iss53


git branching
Ref:Pro-Git Book Merging

$ git checkout master
$ git merge iss53


git merging
Something wrong??

$ git merge iss53
Auto-merging merging.txt
CONFLICT (content): Merge conflict in merging.txt
Automatic merge failed; fix conflicts and then commit the result.


<<<<<<< HEAD:merging.txt
Here is the original change.
=======
Here is the modified change.
>>>>>>> iss53:merging.txt

Ref::Pro-Git Book Rebase

$ git checkout experiment
$ git rebase master

git rebase
Trivia Time
  • Git & Binary Files?

  • Do you have to use Vim as the editor?

  • Are you restricted to a single remote repository?

  • Additional Resources
  • Github | Try Git in your browser
  • Git Documentation
  • Pro-Git Book
  • Git Reference
  • A Visual Git Reference
  • Learn Git Branching
  • Use a spacebar or arrow keys to navigate