ubantu下
1 安装
sudu apt-get install git
老版本可能需要使用sudo apt-get install git-core(因为老版本git是一个gnu的软件)
2 使用
1)创建一个目录(当做是一个项目的目录)
2)进入目录下,$git init 初始化git
新建一个文件作为例子,然后可以使用git查看文件是否被修改,修改内容。
3)
$touch file1 ,新建一个文件
$git add file1 ,将file1添加到git
$git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: file1
#
# Changes not staged for commit:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
终端显示,新添加文件file1
$ls > file1,将列表内容重定向到file1
$git add file1 ,再次将file1提交到git
$git diff file1
diff --git a/file1 b/file1
index e69de29..c2a115a 100644
--- a/file1
+++ b/file1
@@ -0,0 +1,3 @@
+file1
//+号后面就是刚刚重定义的内容
$git commit -m "add file name to file1"
可以提交“注释”,方便查看对于修改的解释
$git log file1
Author: xxx <xx@xx.com>
Date: Wed Oct 8 19:50:44 2014 -0700
add distribute
commit 0abd718832571200b8c56f9f169ada151b846603
Author: admin <870360524@qq.com>
Date: Wed Oct 8 19:35:41 2014 -0700
add file1 to project
显示“注释内容”