linux git pull 失败,解决git pull到github不成功的问题
網上也有很多帖子,但是配置時依舊遇到了一些問題,給自己稍微總結一下。
1.安裝git(linux系統,其他系統自行百度)
$sudo apt-get install git
2.完成基本配置
$git config --global user.name "Your Name"
$git config --global user.email "email@example.com"
3.生成SSH key
$ssh-keygen -t rsa -C “email@example.com”
4.將生成的ssh key添加進github
ssh key所在文件夾?$ cat ~/.ssh/id_rsa.pub
5.mkdir一個本地文件夾作為 代碼倉庫,在github 中new 一個repository
注意:兩個名字一樣
6.pull到github
touch README.md //創建一個README.md文件
echo "# test" >> README.md //向文件中加入一句話“#test”
git init //將該目錄變成git可管理的倉庫
git add README.md //將文件添加到倉庫
git commit -m "first commit" //第一次提交,提交說明 “first commit”
git remote add origin git@github.com:smallDou/test.git //關聯github,smallDou為你的用戶名,test為你創建的repository名
git push -u origin master //推送到github上
7.出現問題:
問題一:
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
解決方法:本地作為git倉庫名和github上new的repositity名字一樣
$git remote rm origin //取消關聯庫
問題二:
To git@github.com:smallDou/jsTest.git
! [rejected] ? ? ? ?master -> master (fetch first)
error: 無法推送一些引用到 'git@github.com:smallDou/jsTest.git'
提示:更新被拒絕,因為遠程倉庫包含您本地尚不存在的提交。這通常是因為另外
提示:一個倉庫已向該引用進行了推送。再次推送前,您可能需要先整合遠程變更
提示:(如 'git pull ...')。
提示:詳見 'git push --help' 中的 'Note about fast-forwards' 小節。
解決方法:按照說明 git pull一下,看會不會自動合并,,如果不會,手動合并
$git pull
warning: no common commits
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
展開對象中: 100% (3/3), 完成.
來自 github.com:smallDou/jsTest
* [新分支] master -> origin/master
當前分支沒有跟蹤信息。
請指定您要合并哪一個分支。
詳見 git-pull(1)。
git pull 如果您想要為此分支創建跟蹤信息,您可以執行:
git branch --set-upstream-to=origin/master
$git pull git@github.com:smallDou/jsTest.git master
$git push -u origin master
完成。
總結
以上是生活随笔為你收集整理的linux git pull 失败,解决git pull到github不成功的问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux下wma转换mp3统一音量的方
- 下一篇: 2021年计算机一级b,2021年全国计