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

 

转载于:https://www.cnblogs.com/xiefei/p/6022889.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值