1、git status命令可以让我们时刻掌握仓库当前的状态,上面的命令告诉我们,readme.txt被修改过了,但还没有准备提交的修改。
2、git diff顾名思义就是查看difference,显示的格式正是Unix通用的diff格式,可以从上面的命令输出看到,我们在第一行添加了一个“distributed”单词。
3、知道了对readme.txt作了什么修改后,再把它提交到仓库就放心多了,提交修改和提交新文件是一样的两步
- 第一步是git add:$ git add readme.txt
- 第二步是git commit -m "xxxxx"
如果只在本地修改,还没有commit,那么用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: conf/gitolite.conf
#
no changes added to commit (use "git add" and/or "git commit -a")
commit之后,用git status,打印信息为:
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
nothing to commit (working directory clean)
说明没有文件需要commit,但是本地仓库 有一个commit ahead原来的master,就是本地仓库有一个提交,比远程仓库要先进一个commit。git push origin master之后,再用git staus,打印信息为:
# On branch master
nothing to commit (working directory clean)