How to prevent registered files from overwriting local versions?

I have some platform modifications for verification files. How to get git to support the local version and ignore the remote one when I merge with the remote branch? Mostly like git -ignore, but for files that are already being tracked by the repository.

A use case is that I click on one branch and then pull this branch on different platforms for testing. Performing testing for the first time on each platform requires a launch. / configure script that modified some configuration files for a specific platform. Since these changes are automatically generated, I do not want to pass them to the history. I usually add these files to .gitignore, however some of these files are part of the original repository, so ignoring git is ignored.

+4
source share
3 answers

, , git pull, , , , , .

+4

.

, HEAD git merge A. git checkout A -- path_of_the_file_you_want_to_keep, A.

. git status, , . , , .

HEAD ORIG_HEAD git, git checkout ORIG_HEAD -- path_of_the_file_you_want_to_keep sha1.

0

. .

If your project needs a file called (for example) config.txt, put this file name in .gitignoreand check the file with a different name, for example config.sample.txt, in the repository. If you want a fantasy, you can force the application to automatically copy the file from config.sample.txtto config.txtif this file does not already exist.

0
source

All Articles