简体   繁体   中英

How to prevent git merge upstream to delete files

I forked a project which has a specific folder. (app/themes/theme_name)

Since, the folder was deleted from the main repository.

I need to preserve the folder in my current project (cause I am still working on it). Basically I want to be able to merge my upstream without deleting files I'm still using.

One solution would be to rename files but I think it will loose the history.

Is there another solution? Thanks

  • update : merge not fetch

If git's merge does almost exactly what you want, often the best way to get exactly what you want is to run it --no-commit and fix up the result manually:

git merge --no-commit
git checkout HEAD -- app/themes/theme_name
git commit

Nothing says you have to use git's default merge driver at all, and git's built so its merge cooperates very well with usage like this.

使这些文件不被git跟踪

git rm --cached filename

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM