I am trying to push an amended commit from one repo to another (on a different machine) and am having trouble understanding why it is not working a second time.
My session (edited, but still relevant):
[/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
Works, right? Let's make some changes and try again:
[/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.
Fails... But, why? I have not even checked out the branch on the remote to make any changes. How can my current branch be behind the remote? This makes no sense to me.
My remote setup:
[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)