git学习01- 下载安装&初始化库&提交

1、windows下安装git,git官网下载安装包安装

2、本地创建一个目录,在目录下创建1个文本 readme.txt

3、cmd进入到该目录,执行git init,初始化git仓库

4、添加文件到git仓库中

  ① git add reame.txt

  ② git commint -m "message"

 5、修改readme.txt

6、在cmd下执行git status查看仓库状态,可知晓该文件被修改,但还没有提交

D:\learn\git_test>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")

 7、可使用git diff readme.txt修改前后的差别

D:\learn\git_test>git diff readme.txt
diff --git a/readme.txt b/readme.txt
index f362e74..f137c15 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

8、使用add命令,添加待提交的文件,提交前、提交后使用git status命令查看,如下

D:\learn\git_test>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")

D:\learn\git_test>git add readme.txt

D:\learn\git_test>git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   readme.txt


D:\learn\git_test>git commit -m "add a distributed word"
[master a915e7b] add a distributed word
 1 file changed, 1 insertion(+), 1 deletion(-)

D:\learn\git_test>git status
On branch master
nothing to commit, working tree clean

猜你喜欢

转载自www.cnblogs.com/minx555/p/10758226.html
今日推荐