Studyon Minte9.com
Git




Basic commands



        INIT
		$ git init 
			// initialize a repository in current directory
			// at this point nothing is tracked

	ADD
		$ git add .
			// add everything from directory to version-controlling
			// this add the file to the staging area

	COMMIT
		$ git commit -m "first commit"
			// this commit the file to the main area

	STATUS
		$ git status
			# On branch master
			# nothing to commit (working directory clean)
			// checking the status of your files
			// no 'tracked' files were modified
			// the are no new 'untracked' files
			// current branch is 'master'

		$ git status
			// after added a new.txt file
			// will tell: 'new file: nex.txt'

		$ git add new.txt
			// add new.txt to staging area
		
		$ git status
			# after some modification on test.txt file
			# new file:   new.txt
			# modified:   test.txt

	DIFF
		$ git diff
			// after adding a line to text.txt
			// you can see the differences between staging and master area
			// before commiting

		$ git add test.txt
			// after every modification you must add again the file
			// to staging
			// otherwise changes will not be commited

		$ git diff --cached
			// will show you what you staged so far

		$ git commit -m "first commit"
			// everything that it is still unstaged
			// or file created or modified that you haven't run 'add'
			// will stay as modified files on your disk

	COMMIT -A

		$ git commit -a -m "avoid staging area"
			// this way you don't need to use 'add' after every modification
			// will skip staging area


	DELETE

		$ git status
			// if you delete a file from directory
			# Changes not staged for commit:
			#   (use "git add/rm <file>..." to update what will be committed)
			#
			#       deleted:    grit.gemspec     deleted:    grit.gemspec

		$ git rm test2.txt

		$ git status
			
			# Changes to be committed:
			#   (use "git reset HEAD <file>..." to unstage)
			#
			#       deleted:    grit.gemspec

		$ git commit -m "delete test2.txt"


	RENAME

		$ git mv test.txt test3.txt


	LOG
		$ git log
			// viewing the commit history

		$ git log --since=2.weeks
			// limiting the log
			// since, after, etc


http://git-scm.com/book/en/git-basics