Last Updated: October 04, 2020
·
4.354K
· freiden

Git merge upstream: Prevent files to be deleted

Sometimes when merging upstream from a forked repo, you could have some conflict with files deleted from the origin but still useful for you.
The following command will explain how to prevent those files to be deleted from your fork during the merge of the upstream.

Retrieve data from upstream

git remote update
git merge upstream/origin

Remove modification done to altered file

git reset HEAD <file>
git co -f <file>

Then pursue merge process

Related protips:

fatal: refusing to merge unrelated histories