git本地无法上传到远程的问题解决方法 |
您所在的位置:网站首页 › git推送项目到远程服务器怎么关闭 › git本地无法上传到远程的问题解决方法 |
git本地无法上传到远程的问题解决方法
正常的创建本地git仓库然后上传到远程的方案参考另一篇博客: 用git建立本地仓库并与远程仓库连接 但是在push过程中可能出现无法连接的问题, 本文将对常见的具体问题和解决方案进行总结. 1. Please make sure you have the correct access rights and the repository exists这个是公钥出问题了,也就是git服务器没有存储本地ssh密钥, 需要重新获取公钥, 具体的解决方法可以参考如下链接: https://blog.csdn.net/lw545034502/article/details/90696872 1.1 项目文件夹目录下配置git git config --global user.name "yourname" git config --global user.email "[email protected]" 1.2 生成公钥在终端对话框(ubuntu)或git shell(windows)中输入: ssh-keygen -t rsa -C "[email protected]" #请填你设置的邮箱地址)如果成功, 则会显示以下内容: Generating public/private rsa key pair. Enter file in which to save the key (/Users/your_user_directory/.ssh/id_rsa):注意如果之前就有公钥, 只是失效了, 会提示是否覆盖, 选择"Y", 然后一路回车(不设置密码, 需要的话在提示设置密码的时候填一下) 成功之后, 显示: The key's randomart image is: +---[RSA 2048]----+ | . . | | . = . . o| |o o * . . ...| |E oo o . o.. | | B . o S . ... | |. o o .o.. | | . o**. | | .B=+%. | | +*BoBo | +----[SHA256]-----+然后系统会自动在.ssh文件夹下生成两个文件,id_rsa和id_rsa.pub,具体的.ssh文件夹目录信息已经显示在对话框中, 一般为: username/.ssh/id_rsa.pub用gedit编辑器打开id_rsa.pub gedit xx/.ssh/id_rsa.pub #xx是.ssh文件夹的目录复制全部内容 1.3 远程更新公钥打开github网站, 登录自己的账户, 点击"设置", 进入ssh设置, New SSH Key, 然后将刚才复制的内容全部粘贴到Key中, 点击add ssh key, 完成. 2. 拒绝上传解决了密钥问题, 在push的过程中可能还会出现以下问题: ! [rejected] master -> master (fetch first) error: failed to push some refs to '[email protected]:KatelynLiu/SynMultiSensors.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.原因 : 本地仓库和远程仓库的文件不一致, 即github允许本地仓库有的东西, 远程仓库里没有, 但不允许远程仓库有的东西, 本地仓库没有. 解决办法 : 在push之前先同步一下本地仓库与远程仓库的文件。使用以下命令 git pull --rebase origin master成功后会显示 warning: no common commits remote: Enumerating objects: 3, done. remote: Counting objects: 100% (3/3), done. remote: Compressing objects: 100% (2/2), done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (3/3), done. From github.com:KatelynLiu/SynMultiSensors * branch master -> FETCH_HEAD * [new branch] master -> origin/master First, rewinding head to replay your work on top of it... Applying: Synchronize multi sensors data from rosbag Applying: synchronize multi sensors data然后就可以正常push自己的代码了 git push origin master如果上述方法仍有问题, 可以试试输入 git push -f转载请声明出处 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |