使用Git 本地代碼提交到 GitHub
阿新 • • 發佈:2017-11-03
解決 bsp username repo creat 用戶名 nbsp png pre 2、執行
3、執行
第一步:下載Git 工具 在官網下載 https://git-scm.com/
第二部:註冊官方賬號 創建一個村代碼的倉庫 註冊地址 https://github.com/
第三部:本地代碼 通過Git 上傳到我們在 GitHub 上創建的倉庫
1.創建一個新的倉庫
進入到你本地項目的根目錄下,執行 git init
命令
2、執行 git add .
命令,將項目的所有文件添加到倉庫中
3、執行git commit -m "註釋語句"
命令,將索引內容添加到倉庫中
4、在 Github 新建一個 Repository
5、點擊Create repository,跳轉到如下頁面,獲取所創建的倉庫的HTTPS地址
6、將本地的倉庫關聯到Github上
git remote add origin https://github.com/……(你的用戶名)/Test.git(你項目的名字)
7、上傳代碼到github遠程倉庫
git push -u origin master
中間可能會需要讓你輸入Username和Password,輸入github的賬號和密碼就行了。
8、成功上傳文件
使用Git出錯:
情況一.
情況二、github中的README.md文件不在本地代碼目錄中
可以通過如下命令進行代碼合並【註:pull=fetch+merge]
git pull --rebase origin master
情況三、github上傳時出現error: src refspec master does not match any解決辦法
錯誤原因:
引起該錯誤的原因是,目錄中沒有文件,空目錄是不能提交上去的
解決方法:
touch README git add README git commit -m ‘first commit‘ git push origin master
使用Git 本地代碼提交到 GitHub