Studyon Minte9.com
Git




Undoing things



* Changing your last commit

	-- rename test.txt -> test3.txt

	$ git commit -m "initial commit"
		// rename test.txt => test3.txt

	-- add new file: new.txt

	$ git commit --amend -m "amend commit"

	-- this second commit replaces the first one

		// 2 files changed, 0 insertions(+), 0 deletions(-)
		// create mode 100644 new.txt
		// rename test.txt => test3.txt (100%)

	
* Unstaging a staged file

	-- modify test3.txt

	1) $ git status
		# On branch master
		# Changes not staged for commit:
		#   (use "git add <file>..." to update what will be committed)
		#   (use "git checkout -- <file>..." to discard changes in working directory)
		#
		#       modified:   test3.txt
	
	2) $ git add test3.txt

	3) $ git status

		# On branch master
		# Changes to be committed:
		#   (use "git reset HEAD <file>..." to unstage)
		#
		#       modified:   test3.txt

	4) $ git reset HEAD test3.txt
		# Unstaged changes after reset:
		# M  test3.txt

	5) $ git status
		# On branch master
		# Changes not staged for commit:
		#   (use "git add <file>..." to update what will be committed)
		#   (use "git checkout -- <file>..." to discard changes in working directory)
		#
		#       modified:   test3.txt

		// back to step 1


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