6 版本管理

修改之前提交的 new 1.txt 文件,改为:

Git is a distributed version control system.
Git is free software.

此时,可以通过运行 git status 命令来查看仓库的当前状态

$ git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   new 1.txt

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

输出显示文件 new 1.txt 已经被修改过了,但是还没有提交。

如果想查看文件被修改的内容,可以通过命令 git diff 来查看:

$ git diff
diff --git a/new 1.txt b/new 1.txt
index d8036c1..013b5bc 100644
--- a/new 1.txt
+++ b/new 1.txt
@@ -1,2 +1,2 @@
-Git is a version control system.
+Git is a distributed version control system.
 Git is free software.
\ No newline at end of file

通过输出可以看到 new 1.txt 文件的第一行被修改,也可以看到具体修改内容的前后对比

提交修改和提交新文件的步骤相同
第一步 git add
$ git add new\ 1.txt

此时再查看仓库状态

$ git status
On branch master
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   new 1.txt

输出显示,将要被提交的修改包括 readme.txt

第二步 git commit
$ git commit -m "Second TXT file"
[master ce29c7e] Second TXT file
 1 file changed, 1 insertion(+), 1 deletion(-)

提交后,再次查看仓库状态:

$ git status
On branch master
nothing to commit, working tree clean

输出显示当前没有需要提交的修改,工作目录是干净的。

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值