git使用-Bug记录

BUG:在提交时遇到了以下的错误。

! [rejected] main -> main (fetch first) error: failed to push some refs to 'https://github.com/X/X.git'

Administrator@DESKTOP-EHVOK0M MINGW64 /I/Github/X (main)
$ git push -u origin main
To https://github.com/Z/Y.git
 ! [rejected]        main -> main (fetch first)
error: failed to push some refs to 'https://github.com/X/X.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

Administrator@DESKTOP-EHVOK0M MINGW64 /I/Github/y(main)
$ git pull
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 732 bytes | 38.00 KiB/s, done.
From https://github.com/X/Y
   d05eadd..05df05b  main       -> origin/main
Auto-merging ReadMe.md
Merge made by the 'recursive' strategy.
 ReadMe.md | 3 +++
 1 file changed, 3 insertions(+)

接着使用命令:git push -u origin main

$ git push -u origin main
Enumerating objects: 17, done.
Counting objects: 100% (17/17), done.
Delta compression using up to 8 threads
Compressing objects: 100% (13/13), done.
Writing objects: 100% (13/13), 838.95 KiB | 23.30 MiB/s, done.
Total 13 (delta 4), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (4/4), completed with 2 local objects.
To https://github.com/X/Y
   05df05b..0ba6e6a  main -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.

就可以成功解决啦~

猜你喜欢

转载自blog.csdn.net/weixin_42888638/article/details/129212408