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 This | Type This |
| Create a repo in CWD | git 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 repo | git commit |
| Put and track content of updated/new files in CWD and below into repo (combines add and commit) | git commit -a |
| Status | git status |
| Copy a project from a master repo | git clone url_goes_here |
| Put your changes back in the master | git push |
| Discover what you SHOULD have added | git diff |
| Show what will get committed | git diff --cached |
| Show what will get commited (alt.) | git status |
| Abandon (completely destroy) a branch | git branch -D branch_name |
| Show commit history [with metrics] | git log [--stat] |
| Compare two branches | git diff master..my_branch |
| Compare CWD with a version | git diff some_branch |
| Show what changed in this_dir since last commit | git diff HEAD -- ./this_dir |
| Do a file system based clone | git clone /path/to/master/for/project myrepo_dir |
| Push a local repo to a NEW remote 'master' repo | git clone --bare repo_original repo_bare |
Basic workflow. Suppose you're about to implement a feature you'll call Feature-X:
Add new comment