標籤:word appdata 命令列介面 repo erro title config檔案 fat 目錄
注意:安裝的前提條件是配置好Git的相關環境或者安裝好git.exe,此處不再重點提及
上傳的步驟:
本文採用git 命令介面進行操作,先執行以下兩個命令,配置使用者名稱和email【設定用戶名和e-mail地址。這是非常重要的,因為每次Git提交都會使用該資訊。它被永遠的嵌入到了你的提交中】
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
然後開始建立項目並提交至遠程git倉庫,步驟如下:
1.進入本地的項目目錄,右鍵“Git Bash here”,調出git命令列介面,然後輸入
git init
2.將目錄下的所有檔案上傳,也可以將“.”換成具體的檔案名稱
git add .
3.將項目提交到本地倉庫
git commit -m "備註陳述式"
4. 在github上建立新的repository
5. 點擊 “Create repository”跳轉到一個串連,如下紅色圈擷取到本項目的github地址
6. 將本地的代碼關聯到github上
git remote add origin 項目的github地址
7. 上傳代碼到github之前需要先pull
git pull origin master
8.上傳代碼到遠程git倉庫
git push -u origin master
9.輸入自己github的帳號,密碼,代碼會成功上傳上去
到此步,代碼已成功上傳至遠程倉庫。
--------------------------------------------------------------- 以下是可能出現的錯誤 --------------------------------------------------------------
如果輸入$ git remote add origin [email protected]:djqiang(github帳號名)/gitdemo(項目名).git
提示出錯資訊:fatal: remote origin already exists.
解決辦法如下:
1、先輸入$ git remote rm origin
2、再輸入$ git remote add origin [email protected]:djqiang/gitdemo.git 就不會報錯了!
3、如果輸入$ git remote rm origin 還是報錯的話,error: Could not remove config section ‘remote.origin‘. 我們需要修改gitconfig檔案的內容
4、找到你的github的安裝路徑,我的是C:\Users\ASUS\AppData\Local\GitHub\PortableGit_ca477551eeb4aea0e4ae9fcd3358bd96720bb5c8\etc
5、找到一個名為gitconfig的檔案,打開它把裡面的[remote "origin"]那一行刪掉就好了!
如果輸入$ ssh -T [email protected]
出現錯誤提示:Permission denied (publickey).因為新產生的key不能加入ssh就會導致連接不上github。
解決辦法如下:
1、先輸入$ ssh-agent,再輸入$ ssh-add ~/.ssh/id_key,這樣就可以了。
2、如果還是不行的話,輸入ssh-add ~/.ssh/id_key 命令後出現報錯Could not open a connection to your authentication agent.解決方法是key用Git
Gui的ssh工具產生,這樣產生的時候key就直接儲存在ssh中了,不需要再ssh-add命令加入了,其它的user,token等配置都用命令列來做。
3、最好檢查一下在你複製id_rsa.pub檔案的內容時有沒有產生多餘的空格或空行,有些編輯器會幫你添加這些的。
如果輸入$ git push origin master
提示出錯資訊:error:failed to push som refs to .......
解決辦法如下:
1、先輸入$ git pull origin master //先把遠程伺服器github上面的檔案拉下來
2、再輸入$ git push origin master
3、如果出現報錯 fatal: Couldn‘t find remote ref master或者fatal: ‘origin‘ does not appear to be a git repository以及fatal:
Could not read from remote repository.
4、則需要重新輸入$ git remote add origin[email protected]:djqiang/gitdemo.git
如何用git命令列上傳本地代碼到github