Git 无法push远程仓库 Note about fast-forwards

1、报错信息:更新被拒绝,因为您当前分支的提示落后,See the ‘Note about fast-forwards’ in ‘git push --help’ for details.

User@6-cpgh0065 MINGW64 /d/code (feature-notification-ghh|MERGING)
$ git push origin feature-notification-ghh
 ! [rejected]            feature-notification-ghh -> feature-notification-ghh (non-fast-forward)
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.

错误:non-fast-forward
远程仓库:feature-notification-ghh
远程分支:feature-notification-ghh
本地分支:feature-notification-ghh

2、解决方法:

Git 已经提示我们,先用 git pull 把最新的内容从远程分支(origin/master)拉下来,但是在 git pull 时,还有其他的错误:

$ git pull --rebase
remote: Enumerating objects: 38, done.
remote: Counting objects: 100% (38/38), done.
remote: Compressing objects: 100% (25/25), done.
remote: Total 38 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (38/38), 14.37 KiB | 55.00 KiB/s, done.
From code
   bc32f26fc..8578b4ece  feature-incidentscreen-guandian-new -> origin/feature-incidentscreen-guandian-new
There is no tracking information for the current branch.
Please specify which branch you want to rebase against.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> feature-notification-ghh

原因是没有指定本地 feature-notification-ghh 分支和远程 origin/feature-notification-ghh 的连接,这里根据提示需要执行:

 git branch --set-upstream-to=origin/feature-notification-ghh feature-notification-ghh

3、完整的解决过程:

① 指定本地 feature-notification-ghh 分支和远程 origin/feature-notification-ghh 的连接:

git branch --set-upstream-to=origin/feature-notification-ghh feature-notification-ghh

② 拉取远程分支的代码并合并到本地分支:

 # 方式1
 git pull --reabse

 # 方式2
 git pull origin feature-notification-ghh

pull 还可能产生 conflict,这里需要自己手动解决冲突再 merge,解决冲突我们可以使用idea来解决

在idea中,找到version control–>local changes即可看到冲突的代码,点击resolve,选择accept yours还是选择accept theirs

④ 解决完冲突之后,查看状态并提交到远程仓库:

$ git status -s

User@6-cpgh0065 MINGW64 /d/code  (feature-notification-ghh|MERGING)
$ git add ./

User@6-cpgh0065 MINGW64 /d/code  (feature-notification-ghh|MERGING)
$ git commit -m ”处理冲突“
[feature-notification-ghh 41bb92bfc] ”处理冲突“

⑤ 将代码推送到远程:

User@6-cpgh0065 MINGW64 /d/code  (feature-notification-ghh)
$ git push origin feature-notification-ghh
Enumerating objects: 97, done.
Counting objects: 100% (97/97), done.
Delta compression using up to 6 threads
Compressing objects: 100% (34/34), done.
Writing objects: 100% (42/42), 4.15 KiB | 303.00 KiB/s, done.
Total 42 (delta 24), reused 0 (delta 0), pack-reused 0

User@6-cpgh0065 MINGW64 /d/code/ngsoc/ngsoc (feature-notification-ghh)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

我一直在流浪

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值