欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 运维知识 > linux >内容正文

linux

linux git pull 失败,解决git pull到github不成功的问题

发布时间:2024/1/1 linux 43 豆豆
生活随笔 收集整理的这篇文章主要介绍了 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不成功的问题的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。