I’m going to ignore most distributed aspects of git in this posting. This content addresses solo developer projects. Note that CWD is an abbreviation for your current working directory.

I use git on my laptop for most work, and when I have a 'milestone product,' I push that to my server.

To Do ThisType This
Create a repo in CWDgit init
Add content of CWD to git's tracking (if CWD is repo root or descendant)git add .
Put all tracked content of CWD and below into repogit commit
Put and track content of updated/new files in CWD and below into repo (combines add and commit)git commit -a
Statusgit status
Copy a project from a master repogit clone url_goes_here
Put your changes back in the mastergit push
Discover what you SHOULD have addedgit diff
Show what will get committedgit diff --cached
Show what will get commited (alt.)git status
Abandon (completely destroy) a branchgit branch -D branch_name
Show commit history [with metrics]git log [--stat]
Compare two branchesgit diff master..my_branch
Compare CWD with a versiongit diff some_branch
Show what changed in this_dir since last commitgit diff HEAD -- ./this_dir
Do a file system based clonegit clone /path/to/master/for/project myrepo_dir
Push a local repo to a NEW remote 'master' repogit clone --bare repo_original repo_bare

  • In your commit message, the first line MUST be a summary line.
  • One-time tasks, after you install git, before you use it for the first time
    • git config --global user.name "Your Name"
    • git config --global user.email "your_mailbox@example.com" </ul>
    • Note that adding a file is not permanent. If you add+edit+commit+edit2+commit2, your file won't be included in commit2 (unless you do a "commit -a" to add+commit). </ul>

      Basic workflow. Suppose you're about to implement a feature you'll call Feature-X:

      • cd somewhere_in_your_git-enabled_project
      • git branch Feature-X
        • This creates the branch, but does not make it your active branch. </ul>
        • git checkout Feature-X
          • This makes Feature-X your active branch. </ul>
          • Lotsa editing
          • git commit -a
          • test and edit some more
          • git commit-a
          • git checkout master
            • Makes 'master' your active branch. </ul>
            • git merge Feature-X
            • If the merge doensn't go smoothly:
              • git diff
              • More editing
              • git commit -a </ul>
              • Regression testing, and maybe more commits.
              • git branch -d Feature-X </ul>