An amend last commit would by default trigger an "behind its remote counterpart" error on git push
, if that mast commit was previously pushed.
It changes the last commit done:
-x--x--x (master, origin/master)
Change the last commit with amend:
-x--x--X' (master)
\
x (origin/master)
"can't pull from unrelated histories" can happen if the remote repository has only one commit: changing the local one means: no common ancestor.
(If not, read "“refusing to merge unrelated histories” failure while pulling to recovered repository")
You can pull allowing for unrelated history to be merged
git pull origin master --allow-unrelated-histories
git merge origin origin/master
... or you can simply, if you are the only one working on the remote repo, force the push.
git push --force