报错原因
git在push时报error: failed to push some refs to 'git@xxx.xx.git’异常,是因为在你要提交之前有人提交了代码,所以产生了冲突造成的,你需要先拉去最新的代码,之后在进行提交即可。
详细的错误信息
[root@xxx pull-image]# git push origin masterEnter passphrase for key '/root/.ssh/id_ed25519':To git@xxxx/xxx.git! [rejected] master -> master (fetch first)error: failed to push some refs to 'git@xxx/xx.git'hint: Updates were rejected because the remote contains work that you dohint: not have locally. This is usually caused by another repository pushinghint: to the same ref. You may want to first merge the remote changes (e.g.,hint: 'git pull') before pushing again.hint: See the 'Note about fast-forwards' in 'git push --help' for details.
解决方法
先拉去最新的代码,之后在进行提交,命令如下
git pullgit push origin master
[root@xxxx pull-image]# git pullEnter passphrase for key '/root/.ssh/id_ed25519':remote: Enumerating objects: 6, done.remote: Counting objects: 100% (6/6), done.remote: Total 6 (delta 0), reused 0 (delta 0), pack-reused 0Unpacking objects: 100% (6/6), done.From xxxxd0f596b..c5164d7 master-> origin/masterMerge made by the 'recursive' strategy.README.md | 8 +++-----1 file changed, 3 insertions(+), 5 deletions(-)[root@xxxxpull-image]# git push origin masterEnter passphrase for key '/root/.ssh/id_ed25519':Counting objects: 11, done.Delta compression using up to 2 pressing objects: 100% (7/7), done.Writing objects: 100% (9/9), 1.07 KiB | 0 bytes/s, done.Total 9 (delta 0), reused 0 (delta 0)To xxxx/xx.gitc5164d7..81a844c master -> master