0

I am trying to update my repository with my new amended commit. But I do not wish to use git push -f. what could be the other options to do so

Pyou
  • 13
  • 2
  • 2
    Possible duplicate of [Why must I force push after changing a commit message?](https://stackoverflow.com/questions/41003071/why-must-i-force-push-after-changing-a-commit-message) – phd Jun 10 '19 at 23:00
  • https://stackoverflow.com/search?q=%5Bgit%5D+amend+commit+without+%22push+--force%22 – phd Jun 10 '19 at 23:00
  • @phd The linked question *will* really be useful to Pyou to get the overall principles around this, I grant you that, but "Why is it so?" and "How to act now?" are calling for different responses, isn't it? Don't get me wrong, I'm not questionning your judgement here, I'm in fact trying to [assess](https://meta.stackoverflow.com/questions/381754/how-ok-is-it-to-post-an-answer-on-a-maybe-duplicate-question) if answering was a bad move on my part. – Romain Valeri Jun 10 '19 at 23:10

1 Answers1

1

If you don't have the option to rewrite remote history of the branch (or don't want to), take their version as a base and build on it.

If you've already pushed the original commit that you just amended locally, but can't push the new amended version since you don't want to --force it, just make a new commit instead of amending the first one :

# assuming your remote is origin
git reset --soft origin/your-branch
git commit -m "description of the new changes"
git push origin HEAD

But if the amend consisted only of metadata changes (for example, correcting the commit message), you're short of luck, no other options than to either push with force or take the pushed commit as granted.

Romain Valeri
  • 19,645
  • 3
  • 36
  • 61