Thursday, May 17, 2012

Fun with git

mkdir gittest
cd gittest
edit hello.txt
Hello, World!
exit
cat hello.txt
should be the same
git init
git add .
git commit -m "First commit!"
git branch update
git checkout update
cat hello.txt
should be the same
edit hello.txt
Hello, world!
Don't leave me!
save, exit
git add .
git commit -m "Update hello.txt 1"
Hmm. I don't like that. I've already committed!
git checkout HEAD~1 -- hello.txt
It's back!
edit hello.txt
Hello, world!
I love you!
save and exit
git commit -m "Love never dies"
git checkout master
cat hello.txt
It's gone?
git checkout update
cat hello.txt
It's back!
git log 
I need that entry n commits ago, but just for hello.txt
git checkout HEAD~n -- hello.txt

No comments:

Blog Archive