Git Basics

    1. Initializing a Repository in an Existing Directory
      git init
    2. Cloning an Existing Repository
      git clone https://github.com/libgit2/libgit2
      git clone https://github.com/libgit2/libgit2 mylibgit
      git clone git://
      git clone ssh://user@server:path/to/repo.git
    3. Checking the Status of Your Files
      git status
    4. Short Status
      git status -s
    5. Viewing Your Staged and Unstaged Changes
      git diff
    6. Committing Your Changes
      git commit
      git commit -m "Story 182: Fix benchmarks for speed
    7. Removing Files
      rm grit.gemspec
    8. Moving files
      git mv file_from file_to
    9. Viewing the Commit History
      git log
      git log -p -2
      git log --stat
      git log --pretty=oneline
      git log --pretty=format:"%h - %an,%ar : %s"
Useful options for git log --pretty=format
Useful options for git log –pretty=format
    1. Undoing Things
      git commit -amend
    2. Unstaging a Staged File
      git reset HEAD benchmarks.rb
    3. Unmodifying a Modified File
      git checkout -- benchmarks.rb
    4. Showing Your Remotes
      git remote
      git remote -v
    5. Adding Remote Respositories
      git remote add https://github.com/paulbone/ticgit
    6. Fetching and Pulling from Your Remotes
      git fetch [remote-name]
    7. Pushing to Your Remotes
      git push origin master
    8. Inspecting a Remote
      git remote show origin
    9. Removing and Renaming Remotes
      git remote rename pb paul
    10. Listing Your Tags
      git tag
    11. Annotated Tags
      git tag -a v1.4 -m 'my version 1.4'
    12. Lightweight Tags
      git tag v1.4-lw
    13. Sharing Tags
      git push origin v1.5
      git push origin --tags

Chacon, S. & Straub, B (2014), Pro Git, (2ndEdition)(pp. 15-41)