git 学习2

git学习1中,我们已经成功的将new.php加入到git的管理之下,如果我现在重新编辑了new.php 然后保存。那么我现在的new.php 版本和上次提交的版本就有了差别。

接下来使用$git status 来监督仓库当前的状态。键入$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: new.php

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

以上信息告诉我们,new.php被修改,但还没有准备提交的修改。

我们如何查看做了哪些修改呢?

接下来我们用$git diff new.php 命令来查看

$ git diff new.php
diff --git a/new.php b/new.php
index 968c8df..cb1fd58 100644
--- a/new.php
+++ b/new.php
@@ -1,3 +1,5 @@
<?php
+echo '1';
phpinfo();
+echo 'hello world';
?>
\ No newline at end of file

以上结果告诉我们,当前的版本与上一次提交到版本库中的版本差别,增加了echo '1';和echo 'hello world';这两行。

接下来用$git add new.php 和$git commit -m "add two new.php"

然后再用在$git status 查看现在的状态,发现

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

 

posted @ 2016-11-02 14:46  PYTHON&PHP&R  阅读(136)  评论(0编辑  收藏  举报