步驟
GitHub
- 登錄GitHub,新建一個倉庫,獲得倉庫連接
本地
- 安裝git(略)
- 在空目錄運行gitBash
- 執行以下命令
git init
git clone [你的倉庫地址,或者 用ssh也可]
新建 .gitignore 文件,填入不想上傳的文件名或規則
在windows中不能新建空名文件,在gitBash中 touch .gitignore 新建
先上傳這個文件:
1 git add .gitignore
2 git commit -m "init"
3 git push
然後把要上傳的文件移動到這個目錄下,上傳
1 git add *
2 git commit -m "first commit"
3 git push
4 檢查下github上有沒有推送成功
增加空名文件 .js
git add * 不會提交空名文件
git add .js 才能拿到
一些Tip
1 刪除文件
刪除文件
git rm test.txt 從版本庫刪除
git push 推送到遠程
如果刪錯了,還沒push,也就是遠程還有該文件,就pull回來
git pull
不想回退文件,確認無誤,可以在手動刪除文件後git add -u
然後push
2 查看本地倉庫,緩存區等的狀態
git status
3 文件刪除了,但是遠程還有,緩存沒有,git status 存在刪除狀態
4EveryThing-up-to-date
參考:[link](https://www.jianshu.com/p/5ae09ce9c7f2)