美文网首页
git 相关问题记录

git 相关问题记录

作者: 辉涛 | 来源:发表于2022-04-13 14:33 被阅读0次
$ git push origin master
git@gitee.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

需要设置公钥:

 ssh-keygen -t rsa -C 'zhuhuitao_struggle@163.com'

生成公钥
$ git push -u origin master
To gitee.com:SixtecCloud/sixtec-cloud-android-repo.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'gitee.com:SixtecCloud/sixtec-cloud-android-repo.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 origin master
remote: Enumerating objects: 2778, done.
remote: Counting objects: 100% (2778/2778), done.
remote: Compressing objects: 100% (1836/1836), done.
remote: Total 2778 (delta 847), reused 2772 (delta 847), pack-reused 0
Receiving objects: 100% (2778/2778), 55.85 MiB | 10.21 MiB/s, done.
From gitee.com:SixtecCloud/sixtec-cloud-android-repo
 * branch            master     -> FETCH_HEAD
 * [new branch]      master     -> origin/master
fatal: refusing to merge unrelated histories

当执行完pull后,再次提交:

$ git push -u origin master
To gitee.com:SixtecCloud/sixtec-cloud-android-repo.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'gitee.com:SixtecCloud/sixtec-cloud-android-repo.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

hint: Updates were rejected because the tip of your current branch is behind

出现这个错误的原因是git本地仓库的当前版本低于远程仓库的版本(大白话就是:你在github上进行的修改没有同步到本地git仓库中)。

在终端下输入:git push -u origin master -f
这句话执行的后果就是在远程仓库中进行的相关修改会被删除,使远程仓库回到你本地仓库未修改之前的那个版本,
然后上传你基于本地仓库的修改。这如果在企业开发中就会让别的程序员的这些天的开发付之东流,一切回到解放前。

相关解决办法:
https://blog.csdn.net/IT_SoftEngineer/article/details/107133313

相关文章

  • Jenkins git-lfs错误记录

    问题记录: Jenkins构建时报git-lfs相关错误,如: hudson.plugins.git.GitExc...

  • git 相关问题记录

    需要设置公钥: 当执行完pull后,再次提交: hint: Updates were rejected becau...

  • [Git]Git相关问题

    1.fatal: The upstream branch of your current branch does ...

  • git相关问题

    git 常用命令: git clone XX.git 拉取项目; git add 加入本地仓库; git comm...

  • Git基础

    本文记录一些学到的Git相关的基础操作 Git Documentation Git 相关的一些基本概念 图片来源:...

  • git 查看某个文件的修改记录

    git log filename 可以看到fileName相关的commit记录 git log -p filen...

  • git相关操作记录

    git切换分支注意事项: git 切换分支前,需要先 add 将本地的所做的更改暂存一下,切换分支便不会失掉本地的...

  • git相关操作记录

    相关配置 初始化仓库 添加文件 提交 查看git commit的提交记录 转至版本 git 打标签 分支 分支操作...

  • git 相关操作记录

    1.git merge 撤销 首先保证在 merge 时所在分支,如果没在,先切过去: 使用 git reflog...

  • Git总结

    复习用,记录 Git 相关知识 Gitee 没有记录(比较简单),Git 搭建服务器也没有记录(还不太会玩 lin...

网友评论

      本文标题:git 相关问题记录

      本文链接:https://www.haomeiwen.com/subject/sdrasrtx.html