一召廷、通過命令行上傳步驟如下:
cd 到本地工程目錄
git init // 初始化git
git add . // add所有文件
git commit -m "first commit" // 提交到本地倉庫
git remote add origin https://github.com/RiversMaJianCheng/hello-word.git // 項目地址
git push -u origin master // 提交到遠程庫
中間會讓你輸入GitHub賬號和密碼,如果不出意外應該就行了喉恋,但是我的依然出現(xiàn)了意外報如下錯誤:
failed to push some refs to 'https://github.com/RiversMaJianCheng/hello-word.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
然后找到了一個解決方法這時候接著敲入以下命令:
git pull --rebase origin master
git push -u origin master // 提交到遠程庫
以上就解決了本地項目上傳GitHub的問題了悄但!
二棠隐、通過GitHub Desktop 上傳步驟如下:
1.打開GitHub Desktop 客戶端,登錄賬號檐嚣,后如下圖操作:
2.選中本地工程路徑之后點擊Create & Add Repository 按鈕助泽,這就將本地的項目添加到了GitHub Desktop中,接下來我們準備上傳到GitHub中嚎京,如下圖所示:
3.點擊右上角的“Publish”按鈕报咳,在彈出的下拉菜單中,“Name”就是你Repository的名字挖藏,“Description”可以不填。然后點擊“Publish Repository”按鈕厢漩。 如下圖:
稍等片刻后膜眠,等右上角的按鈕變成“Sync”說明GitHub上的倉庫建好文件也同步完成。雙指點擊左側(cè)工程溜嗜,然后選擇View on Github(或者點擊R epositroy 然后選擇 View on Github)就可以到github上面查看了宵膨!