本文轉自博客園,由eedc傾力撰寫,地址:https://www.cnblogs.com/eedc/p/6168430.html
如何用命令將本地項目上傳到git
1、(先進入項目文件夾)通過命令 git init 把這個目錄變成git可以管理的倉庫
git init
2、把文件添加到版本庫中,使用命令 git add .添加到暫存區裏面去,不要忘記後面的小數點“.”,意爲添加文件夾下的所有文件
git add .
3、用命令 git commit告訴Git,把文件提交到倉庫。引號內爲提交說明
git commit -m 'first commit'
4、關聯到遠程庫
git remote add origin 你的遠程庫地址
如:
git remote add origin https://github.com/xxxxx/demo.git
5、獲取遠程庫與本地同步合併(如果遠程庫不爲空必須做這一步,否則後面的提交會失敗)
git pull --rebase origin master
6、把本地庫的內容推送到遠程,使用 git push命令,實際上是把當前分支master推送到遠程。執行此命令後會要求輸入用戶名、密碼,驗證通過後即開始上傳。
git push -u origin master
備:詳細請參考 http://www.cnblogs.com/tugenhua0707/p/4050072.html