1.將目標文件$ git init
打開要上傳的文件夾路徑卖擅,輸入$ git init
.git文件夾
會生成一個.git文件夾顿锰。
2.創(chuàng)建一個.gitignore文件夾
把此文件下不需要上傳的文件放入.gitignore文件夾里面揣非。
.gitignore文件夾
如果所有在此目錄的文件夾都需要上傳曲初,此步驟忽略。
$ touch .gitignore
3.查看當前狀態(tài)
$ git status
4.上傳除.gitignore文件的其他所有文件
git add .
還可以使用git add "文件夾名稱"
上傳單個文件夾衡未。
5.提交上傳的文件
$ git commit -m "對上傳文件版本的描述"
最好不要省略對上傳文件版本的描述晚顷,不然后面可能找不到自己上傳的文件是做了什么工作庞呕。
TYH_LAB@DESKTOP-OFK7U34 MINGW64 ~/PycharmProjects/Mxonline (master)
$ git commit -m "MXonline until vidio 7th"
[master (root-commit)
d3cfb0c] MXonline until vidio 7th
7775 files changed, 885230 insertions(+)
create mode 100644 .gitignore
create mode 100644 Mxonline/__init__.py
....................................
6.遠程連接
git remote add origin https://github.com/keaidoo/keaiduo.git
請把keaidoo改成你自己的GitHub用戶名新翎。keaiduo.git
是你的文件夾名稱,就是你在GitHub上新創(chuàng)建的文件夾住练。
keaiduo.git
7.我出錯了
可能之前我已經(jīng)連接過一次
TYH_LAB@DESKTOP-OFK7U34 MINGW64 ~/PycharmProjects/Mxonline (master)
$ git remote add origin https://github.com/keaidoo/keaiduo.git
fatal: remote origin already exists.
沒關系地啰,remove一下就好。
TYH_LAB@DESKTOP-OFK7U34 MINGW64 ~/PycharmProjects/Mxonline (master)
$ git remote rm origin
沒有提示就是好消息讲逛。代表沒有錯誤啦
8.再次連接
TYH_LAB@DESKTOP-OFK7U34 MINGW64 ~/PycharmProjects/Mxonline (master)
$ git remote add origin https://github.com/keaidoo/keaiduo.git
記得把keaidoo改成你自己的GitHub用戶名哦亏吝。
9.push
$ git push -u origin master
我不幸又出錯了
TYH_LAB@DESKTOP-OFK7U34 MINGW64 ~/PycharmProjects/Mxonline (master)
$ git push -u origin master
fatal: unable to access 'https://github.com/keaidoo/keaiduo.git/': error setting certificate verify locations:
CAfile: D:/Git/mingw64/libexec/ssl/certs/ca-bundle.crt
CApath: none
解決方法:https://github.com/npm/npm/issues/1484
$ git config --global http.sslverify "false"
然后再push一次
git push -u origin master
,成功盏混。
image.png
作者:一個菜菜的程序媛蔚鸥,學習計算機中總是會踩到無數(shù)各種奇奇怪怪的坑,只是找個空間記錄下來许赃,互相學習止喷,歡迎大佬的指教。公眾號:可愛多小姐