pkaramol pkaramol - 1 year ago 75
Git Question

Will git push --force delete remote files?

If i perform a

git push --force <remoterepo> <remotebranch>

will this delete files in the
, if these do not exist in my branch?

(apart of course from prioritizing my local changes over remote ones, when it comes to files existing in both local and remote branches)

Answer Source

The HEAD commit of that remote branch will reflect the commit you are pushing.
If that commit does not include certain files, there won't be in the remote branch HEAD as well.

But their history will be preserved in past commits, unless the push --force rewrite all the commits in which those files were present. That happens typically if your push --force is done after a git filter-branch.