..." to">
赞
踩
创建一个空目录
mkdir gitTest
$ cd gitTest
使用 git init
命令,把这个目录变成Git可以管理的仓库
PS D:\gitTest> git init
Initialized empty Git repository in D:/gitTest/.git/
新增一个文件 readme.txt
Git is a version control system.
Git is free software.
使用 git add
告诉Git,把文件添加到仓库
git add readme.txt
用命令git commit
告诉Git,把文件提交到仓库:-m
后面输入的是本次提交的说明
git commit -m "wrote a readme file"
修改readme.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 checkout -- <file>..." to discard changes in working directory)
modified: readme.txt
no changes added to commit (use "git add" and/or "git commit -a")
虽然Git告诉我们readme.txt
被修改了,要用git diff
这个命令看看修改了什么:
git diff readme.txt
diff --git a/readme.txt b/readme.txt
index 46d49bf..9247db6 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,2 +1,2 @@
-Git is a version control system. 删除了
+Git is a distributed version control system. 新增的
Git is free software. 未修改
修改后,然后再提交 也是使用 git add
,之后看下状态
git add readme.txt
git status
On branch master
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: readme.txt
告诉我们,将要被提交的修改包括readme.txt
,下一步,就可以放心地提交了:
git commit -m "add distributed"
[master c2add21] add distributed
1 file changed, 1 insertion(+), 1 deletion(-)
提交后,再看下状态
git status
On branch master
nothing to commit, working tree clean
再次修改文件为
Git is a distributed version control system.
Git is free software distributed under the GPL.
修改好了提交
git add readme.txt
git commit -m "append GPL"
[master 2bb4911]] append GPL
1 file changed, 1 insertion(+), 1 deletion(-)
我们已经修改了三次,可以用 git log
命令查询
git log
commit 2bb4911c23a25048f3c4c19d0b627ac4c06abb00 (HEAD -> master)
Author: tangcy <3247306211@qq.com>
Date: Fri Apr 22 15:50:34 2022 +0800
append GPL
commit c2add212bfe48e658f724521ba541b243b5ab0cc
Author: tangcy &l
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。