Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

does git amend require a git push -f?

Tags:

git

make changes
git commit 'made changes' -a
git push origin
make more changes
git ammend -a
git push origin

I've noticed that when I do a git commit --ammend -a and then try to push to a remote repo, it requires that I force the push (git push -f).

My guess is because it's trying to push the same (?whats the word?) commit code but notices differences in files.

Is this correct / normal?

like image 590
d-_-b Avatar asked Mar 01 '26 06:03

d-_-b


1 Answers

A git commit --amend or a git commit --author=<author>, if anything is modified, will generate a different SHA1.
Then, yes, a git push -f will be needed.

git amend can be defined as an alias like in this blog post:

git config --global alias.amend 'commit --amend -C HEAD'

This alias adds a git amend command that will reuse the current commit message when it amend it.

like image 99
VonC Avatar answered Mar 03 '26 19:03

VonC