【发布时间】:2019-01-29 00:08:01
【问题描述】:
我正在尝试将修改后的提交从一个 repo 推送到另一个 repo(在另一台机器上),并且无法理解为什么它第二次无法正常工作。
我的会话(已编辑,但仍然相关):
[/c/git/repo] (mybranch)
[user] $ git commit -a --amend
[mybranch ad1804290] Add filtering
Date: Thu Jun 21 09:50:43 2018 -0400
26 files changed, 2302 insertions(+), 2006 deletions(-)
[user] $ git push centos7vm mybranch
Counting objects: 157, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (135/135), done.
Writing objects: 100% (157/157), 59.76 KiB | 3.51 MiB/s, done.
Total 157 (delta 121), reused 34 (delta 15)
To ssh://mymachine/home/user/git/repo
* [new branch] mybranch -> mybranch
有效,对吧?让我们进行一些更改,然后再试一次:
[/c/git/repo] (mybranch)
[user] $ git commit -a --amend
[mybranch 26c680cbf] Add filtering
Date: Thu Jun 21 09:55:43 2018 -0400
26 files changed, 2302 insertions(+), 2006 deletions(-)
[/c/git/repo] (mybranch)
[user] $ git push centos7vm mybranch
To ssh://mymachine/home/user/git/repo
! [rejected] mybranch -> mybranch (non-fast-forward)
error: failed to push some refs to 'ssh://user@mymachine/home/user/git/repo'
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.
失败了……但是,为什么?我什至没有检查远程分支上的任何更改。我当前的分支怎么可能在遥控器后面?这对我来说毫无意义。
我的远程设置:
[user] $ git remote show centos7vm
* remote centos7vm
Fetch URL: ssh://user@mymachine/home/user/git/repo
Push URL: ssh://user@mymachine/home/user/git/repo
HEAD branch: development
Remote branches:
Local refs configured for 'git push':
development pushes to development (fast-forwardable)
mybranch pushes to mybranch (local out of date)
【问题讨论】: