Git Quick Guide

FUNDAMENTALS:

A git project has 3 parts:
A Working Directory
A Staging Area: Where you'll list changes you make to the working directory.
A Repository: A permanent store

It's been noted that git has somewhat of a complex conceptual design. "Distinguishing between the working version of a file and the staged version of a file is a common cause of confusion," Adrian Colyer has noted, summing up a paper on the subject.

Git is a utility to manage an append-only repository of tree-objects, blobs and commits, according to one Hacker News commenter, adding that the software is not intended as a black-box program where you can issue commands to get results. "What the hell is wrong with Git," a most-junior developer may say.

Here is a walk-through that illustrates the conceptual model of Git.

GIT FROM THE COMMAND LINE:

git init: Initialize new git repository.

git status: Check condition of current repository.

git add [filename]: Add a file to the staging area

. Multiple file names may be included.

git commit -m "add explanatory text here": Commit file to repository.

After a rule has been edited, it can be moved from staging to be the final version of the file. Comments should be in present tense.

git diff [filename]: Check the difference between two latest versions of a file.

git log: Show changes.

git show HEAD: Show latest changes to file comitted.

git checkout HEAD filename: Revert to previous commit for file.

git reset HEAD filename: Unstage a file from the staging area.

git log: shows all changes, along with commit hash for file.

git reset XXXXXXX: Resets file to a specific commit, using first 7 digits of file's hash (as seen in git commit return).

source: Codecademy

Programming and System Administration Home