#1.創建本地倉庫css
$ mkdir git-demo-1
$ cd git-demo-1
$ git init
Initialized empty Git repository in C:/Users/59793/Desktop/git-demo-1/.git/
複製代碼
建立文件夾,初始化一個空的git倉庫;html
ls -la
total 84
drwxr-xr-x 1 59793 197609 0 3月 30 20:32 ./
drwxr-xr-x 1 59793 197609 0 3月 30 20:31 ../
drwxr-xr-x 1 59793 197609 0 3月 30 20:32 .git/
複製代碼
引用: git status -sb 是什麼意思:
git status 是用來顯示當前的文件狀態的,哪一個文件變更了,方便你進行 git add 操做。-sb 選項的意思就是,SB都能看懂,哈,這是開玩笑,-s 的意思是顯示總結(summary),-b 的意思是顯示分支(branch),因此 -sb 的意思是顯示總結和分支。git
touch index.html
git status -sb
No commits yet on master
?? index.html
mkdir css
git status -sb
No commits yet on master
?? index.html
複製代碼
git 忽略空文件夾github
touch css/style.css
git status -sb
No commits yet on master
?? css/
?? index.html
git add index.html
git status -sb
No commits yet on master
A index.html
?? css/
git add css
git status -sb
No commits yet on master
A css/style.css
A index.html
複製代碼
A: 告訴git這兩個文件都要了;vim
git commit -m "第一次提交"
[master (root-commit) 11b4bd9] 第一次提交
2 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 css/style.css
create mode 100644 index.html
複製代碼
正式提交到本地倉庫;bash
start css/style.css
git add css/style.css
git commit -m "改動"
[master b36a22b] 改動
1 file changed, 1 insertion(+)
複製代碼
添加改動;ssh
git log * 查看更新歷史;*ui
commit b36a22b52ca47bb061a2ebe5d7745de5118b4a23 (HEAD -> master)
Author: clay <claywu@foxmail.com>
Date: Sat Mar 30 21:01:18 2019 +0800
改動
commit 11b4bd954a2d6749f957b8b9337ec61bfd99d534
Author: clay <claywu@foxmail.com>
Date: Sat Mar 30 20:45:31 2019 +0800
第一次提交
複製代碼
1.git init,初始化本地倉庫 .git
2. git status -sb,顯示當前全部文件的狀態
3. git add 文件路徑,用來將變更加到暫存區
4. git commit -m "信息",用來正式提交變更,提交至 .git 倉庫
5. 若是有新的變更,咱們只須要依次執行 git add xxx 和 git commit -m 'xxx' 兩個命令便可。別看本教程廢話那麼多,其實就這一句有用!先 add 再commit。
6. git log 查看變動歷史spa
tree .命令Windows用不了code
#2.同步至GitHub: 1.git remote add origin git@github.com:xxxx/git-demo-1.git,複製並運行它;
2.複製第二行 git push -u origin master,運行它;
#3.下載倉庫:
cd git-demo-1
touch index2.html
git add index2.html
git commit -m "新建 index2.html"
git pull 遠程被修改的狀況下必需要pull
git push
強制退出(不保存):狂按 ESC,而後按下 :q! 回車 保存後退出:狂按 ESC,而後按下 :wq 回車