WMW@WMWGO MINGW64 /f
$ cd e: # 切换到 E 盘
WMW@WMWGO MINGW64 /e
$ mkdir learngit # 创建空目录
WMW@WMWGO MINGW64 /e
$ cd learngit # 切换到 learngit 目录
WMW@WMWGO MINGW64 /e/learngit
$ pwd # 显示当前目录
/e/learngit
WMW@WMWGO MINGW64 /e/learngit
$ git init # 初始化空仓库,目录下会多一个 .git 目录
Initialized empty Git repository in E:/learngit/.git/
WMW@WMWGO MINGW64 /e/learngit (master)
$ ls -ah # 显示隐藏的 .git 目录
./ ../ .git/
WMW@WMWGO MINGW64 /e/learngit (master)
$ git add readme.txt # 将文件添加到仓库(先把 readme.txt 文件置于 learngit 目录下)
WMW@WMWGO MINGW64 /e/learngit (master)
$ git commit -m "wrote a readme file"
# 把文件提交到仓库,引号内为说明
[master (root-commit) c08a390] wrote a readme file
1 file changed, 2 insertions(+)
create mode 100644 readme.txt
WMW@WMWGO MINGW64 /e/learngit (master)
$ 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: readme.txt
no changes added to commit (use "git add" and/or "git commit -a")
WMW@WMWGO MINGW64 /e/learngit (master)
$ git diff # 查看文件内容变化
diff --git a/readme.txt b/readme.txt
index 0065b6f..0a30af0 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 a free software.
\ No newline at end of file
WMW@WMWGO MINGW64 /e/learngit (master)
$ git add readme.txt # 将修改后的文件添加到仓库
WMW@WMWGO MINGW64 /e/learngit (master)
$ git status # 查看当前仓库状态,下方提示文件的修改将被提交
On branch master
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: readme.txt
WMW@WMWGO MINGW64 /e/learngit (master)
$ git commit -m "add contribute"
# 提交修改
[master 79ac4c7] add contribute
1 file changed, 1 insertion(+), 1 deletion(-)
WMW@WMWGO MINGW64 /e/learngit (master)
$ git status # 查看当前查看状态,下方提示没有需要提交的修改
On branch master
nothing to commit, working tree clean
WMW@WMWGO MINGW64 /e/learngit (master)
$
转载于:https://www.cnblogs.com/lonelyWMW/p/11481632.html