Question

I know they exist in git reflog, but if I push a commit to a remote repository, amend, then git push --force (warning: pushing --force to remote repositories should usually be avoided), will the commit that I overwrote exist somewhere?

Was it helpful?

Solution

will the commit that I overwrote exist somewhere?

Only in:


Note that ORIG_HEAD (a memento from a time where reflog didn't existed yet) is not created/updated by a git commit (like a git commit --amend or a git commit --amend -m "new comment").
So if the reflog isn't activated on a repo, ORIG_HEAD cannot be used to reference the amended commit.

OTHER TIPS

No. Your amended commit will stay in your local repo for some time, but it won't be pushed.

When pushing, Git computes the missing commits to have the remote branch at the same point as your local branch. Since your amended commit is not on the branch anymore, it won't be pushed.

An amended commit stays until a garbage collection occur. But GC check several conditions before removing a commit, so don't be afraid of losing data.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top