1、設(shè)置用戶名
git config --global user.name xxx
2、添加到本地
git init //初始化本地倉儲
git add . //添加所有文件到本地倉儲
git commit -m "feat:add" ?//提交到本地
3、在github上創(chuàng)建倉儲
4、生成密鑰
打開Git Shell 輸入如下命令:ssh-keygen -C "your@email.address" -t rsa
密鑰路徑在命令下方顯示
5、設(shè)置github密鑰
打開密鑰生成路徑在.ssh文件夾中用記事本打開id_rsa.pub文件把文件內(nèi)容拷貝。把拷貝的密鑰添加到github密鑰設(shè)置中(需勾選復(fù)選框)。設(shè)置后保存
6、連接到github
git remote add origin https://github.com/test/Test.git(服務(wù)器上的地址)
出現(xiàn)錯誤:
fatal: remote origin already exists
則執(zhí)行以下語句:
git remote rm origin
再次執(zhí)行g(shù)it remote add origin https://github.com/test/Test.git即可。
在執(zhí)行g(shù)it push origin master時,報錯:
error:failed to push som refs to.......
則執(zhí)行以下語句:
git pull origin master
先把遠(yuǎn)程服務(wù)器github上面的文件拉先來,再push 上去