Git学习(第一天)
$ git init Initialized empty Git repository in E:/Git/learngit/.git/
$ ls -ah
Hello Git~ Git is a version control system.
$ git add readme.txt
执行完上面的命令没有任何的提示信息,不是有句话讲的,Unix的哲学是 "没有消息就时好消息",说明添加成功。
$ git commit -m "wrote a readme file" [master (root-commit) 068eefe] wrote a readme file 1 file changed, 2 insertions(+) create mode 100644 readme.txt
git commit命令后面的-m输入的是本次提交的说明(用过SVN的朋友应该都知道这个说明的用处咯),可以输入任意内容,最好是有意义的,因为注意就可以很快速方便的找到你对应的改动记录。
$ git add file1.txt $ git add file2.txt file3.txt $ git commit -m "add 3 files."
$ 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")
从上面的信息可以看出,被修改过的文件是readme.txt,但是还没有被提交。
$ git diff readme.txt diff --git a/readme.txt b/readme.txt index d8036c1..06ba57a 100644 --- a/readme.txt +++ b/readme.txt @@ -1,2 +1,2 @@ -Git is a version control system. +Git is a version control system.Hello Git. Git is free software. \ No newline at end of file
通过上面的命令输出看到,在第一行添加了“Hello Git”
$ git status On branch master nothing to commit, working directory clean
通过上面的命令输出看到,当前没有需要提交的修改文件。