git 学习(一)初始化和提交

git 学习(一)

创建git版本库
$ mkdir gitstudy
$ cd gitstudy
$ git init
nitialized empty Git repository in /Users/fengxi/Documents/gitstudy/.git/

新建一个文件

$ vim
good git
git is a file version control system
:w readme.txt
:q

查看文件

$ ls
readme.txt

提交文件

$ git add readme.txt
$ git commit -m "create readme.txt file"
[master (root-commit) 69a629d] create readme.txt file
1 file changed, 2 insertions(+)
create mode 100644 readme.txt	

修改文件

$vim
:open readme.txt
good git
git is a file version control system
good good study //新添加的
:wq

查看状态

$ 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:   readme.txt

no changes added to commit (use "git add" and/or "git commit -a")

修改内查询

$ git diff readme.txt
diff --git a/readme.txt b/readme.txt
index 058f007..7550558 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,2 +1,3 @@
good git
git is a file version control system
+good good study	

提交修改

$ git add readme.txt

提交前检查

$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

modified:   readme.txt

git提醒我们readme.txt将会被提交

提交

$ git commit -m "add good study"
[master 148ff70] add good study
1 file changed, 1 insertion(+)

提交后再次查看

$ git status
On branch master
nothing to commit, working directory clean

工作目录已经干净了全部都已经提交

posted @ 2015-01-14 04:21  KeithMorning  阅读(328)  评论(0编辑  收藏  举报