查看Git仓库当前状态和修改内容

目录

描述

git status:查看仓库状态

git diff命令


描述

在不确定版本仓库是否有修改的情况下,使用Git命令来查看仓库改动和修改详情。

git status:查看仓库状态

git status命令告诉我们当前仓库的状态。

➜  Code git:(master) git status
On branch master
nothing to commit, working tree clean

上面的内容告诉我们,当前仓库没有改动,因此无需提交新的内容。

当我们在仓库中修改文件后,但是还没有提交时:

➜  Code git:(master) ✗ 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:   test.txt

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

这段提示告诉我们仓库中的test.txt文件被修改了,但目前还没有提交。

git diff命令

git diff命令可以告诉我们仓库中的文件修改了什么。

diff --git a/test.txt b/test.txt
index 4e721ad..7a3b7a6 100644
--- a/test.txt
+++ b/test.txt
@@ -1,2 +1,3 @@
 this is a file.
 Then I will test another git command.
+Good Luck!
(END)

使用git diff命令后,控制台回显出上面的信息。它告诉我们,test.txt文件中增加了一行"Good Luck!"

当我们把改动提交后:

再次使用git diff命令,此时控制台回显:

(END)

说明没有修改后未提交的内容了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值