git使用中遇到的问题

本文介绍了在使用Git时遇到的推送错误[rejected] master->master(fetch first),并提供了两种解决方案:执行`git pull --rebase origin master`后再推送,或者使用`git push -f`强制更新。通过这些步骤,可以成功将本地更改推送到远程仓库。
摘要由CSDN通过智能技术生成

有时候在当我们在进行git push 的有时候会出错[rejected] master -> master (fetch first)
错误代码如下:
/*
海阔天空@F6FR3S0LLSWAHRJ MINGW64 /f/Github/PHP (master)
$ git push
To https://github.com/shumiaozhang/PHP.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to ‘https://github.com/shumiaozhang/PHP.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 push -f 语句 就能成功提交。
此时显示如下:
/

海阔天空@F6FR3S0LLSWAHRJ MINGW64 /f/Github/PHP (master)
$ git push -f
Enumerating objects: 28, done.
Counting objects: 100% (28/28), done.
Delta compression using up to 4 threads.
Compressing objects: 100% (24/24), done.
Writing objects: 100% (28/28), 20.38 KiB | 1.57 MiB/s, done.
Total 28 (delta 7), reused 0 (delta 0)
remote: Resolving deltas: 100% (7/7), done.
To https://github.com/shumiaozhang/PHP.git

  • b6d2e42…4efc435 master -> master (forced update)

海阔天空@F6FR3S0LLSWAHRJ MINGW64 /f/Github/PHP (master)

*/

如果上述解决方式不管用也可以输入:git pull --rebase origin master 之后再进行git push 即可。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值