分类: LINUX
2013-10-20 23:45:49
安装完成后,在开始菜单里找到“Git”->“Git Bash”,蹦出一个类似命令行窗口的东西,就说明Git安装成功!
# git config --global user.name "Your Name" # git config --global user.email "email@example.com"
# mkdir lulu # cd lulu # pwd # git init Initialized empty Git repository in /home/ch/.git/
# touch a b c # git add a b c # git commit -m "add 3 files."
# git status # On branch master # # Initial commit # # Changes to be committed: # (use "git rm --cached..." to unstage) # # new file: a # new file: b # new file: c
# git diff diff --git a/a b/a index 190a180..b1bd38b 100644 --- a/a +++ b/a @@ -1 +1 @@ -123 +13
# git log commit fc9f6f979844121f0281efab8dd8873994718ce4 Author: luluDate: Sat Oct 19 16:49:48 2013 +0800 vim a commit edffae908974fdf18882a0d444a2fe320516a85c Author: lulu Date: Sat Oct 19 16:40:39 2013 +0800 add a b c files
# git log --pretty=oneline fc9f6f979844121f0281efab8dd8873994718ce4 vim a edffae908974fdf18882a0d444a2fe320516a85c add a b c files在Git中,用HEAD表示当前版本,上一个版本就是HEAD^,上上一个版本就是HEAD^^,当然往上100个版本写100个^比较容易数不过来,所以写成HEAD~100。
# git reset --hard HEAD^ HEAD is now at edffae9 add a b c files
# git reflog edffae9 HEAD@{0}: reset: moving to HEAD^ fc9f6f9 HEAD@{1}: reset: moving to fc9f6f9 edffae9 HEAD@{2}: reset: moving to edffae9 fc9f6f9 HEAD@{3}: commit: vim a edffae9 HEAD@{4}: commit (initial): add a b c files
# rm a rm: remove regular file `a'? y
# git rm a rm 'a' # git commit -m "delete a" [master b2ee4aa] delete a 1 file changed, 1 deletion(-) delete mode 100644 a