git 提交代码报错failed to push some refs to 解决笔记
2023-09-27 14:22:25 时间
Administrator@SC-201902081500 MINGW64 /e/gitrepository (master) $ git push django master To github.com:zgc137/django.git ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'git@github.com:zgc137/django.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.
此时很多人会尝试下面的命令把当前分支代码上传到master分支上。
$ git push -u origin master
但依然没能解决问题
出现错误的主要原因是github中的README.md文件不在本地代码目录中
origin是自己在git上创建的仓库名字,我的创建的名字是django
可以通过如下命令进行代码合并【注:pull=fetch+merge]---取+合并
git pull --rebase origin master
注:上传代码到远程库,上传之前最好先Pull一下,再执行命令: git pull origin master
$ git pull --rebase django master Warning: Permanently added the RSA host key for IP address '52.74.223.119' to the list of known hosts. From github.com:zgc137/django * branch master -> FETCH_HEAD First, rewinding head to replay your work on top of it... Applying: wrote a readme file Applying: 天天生鲜项目+练习
即pull成功,
接着执行:git push origin master
$ git push -u django master Enumerating objects: 115, done. Counting objects: 100% (115/115), done. Delta compression using up to 12 threads Compressing objects: 100% (111/111), done. Writing objects: 100% (114/114), 1.44 MiB | 782.00 KiB/s, done. Total 114 (delta 3), reused 0 (delta 0) remote: Resolving deltas: 100% (3/3), done. To github.com:zgc137/django.git eecd635..07115e0 master -> master Branch 'master' set up to track remote branch 'master' from 'django'.
相关文章
- Unity 3D本地公布WebPlayer版时"Failed to download data file"解决方式
- fatal: Authentication failed for解决方法
- 解决错误 sh: 0: getcwd() failed: No such file or directory
- Failed to connect to raw.githubusercontent.com port 443
- dm-0: WRITE SAME failed. Manually zeroing
- 解决Python错误-----SSL: CERTIFICATE_VERIFY_FAILED
- ubuntu下容器无法启动报错"failed to start daemon: failed to dial "/run/containerd/containerd.sock": unknown service containerd.services.namespaces.v1.Namespaces: not implemented"如何处理?
- from torch._C import * ImportError: DLL load failed解决方法
- Android开发在使用第三方推送的时候出现INSTALL_FAILED_VERSION_DOWNGRADE
- scp报错:Host key verification failed. REMOTE HOST IDENTIFICATION HAS CHANGED!
- org.apache.spark.SparkException: Kryo serialization failed: Buffer overflow
- maven failed to execute goal on project