Git使用

1. 下载安装git

linux: sudo apt-install 

windows: https://git-scm.com/download/win

 

2. 打开git bash

 

3. 新建文件夹

mkdir newfile

 

4. 初始化

git init

 

5. 新建文件

vim readme.txt

 

6. 添加文件

git add readme.txt

注意安装时的选项,可能出现警告内容,原因在于windows和linux的换行符不一样

解决办法: git config --global core.autocrlf false

 

7. 上传文件

git commit -m "description"

 

8. 查看状态

git status

未修改则提示

On branch master
nothing to commit, working tree clean

 

9. 修改文件

在readme.txt新增 "new comment"

 

10. 再次查看状态

出现

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")

 

11. 查看修改

git diff

diff --git a/readme.txt b/readme.txt
index e4dfc35..a674dbe 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1 +1,2 @@
UAV formation in lossy network
+new comment

 

12. 上传

git add readme.txt

git commit

 

13. 查看版本

git log

 

14. 恢复版本

git reset

posted @ 2019-04-08 19:31  roov  阅读(4)  评论(0编辑  收藏  举报