Protect Files from Git

I use Git with WindRiver to manage my project. The code is managed, however project files (such as .cproject, .project, .wrmakefile and .wrproject) are not. However, when I switch branches, Git deletes these files, even though they are in .gitignore, thereby removing my ability to compile code without returning a commit or saving a backup.

So, is there a way to tell Git to ignore these files and not touch them no matter what?

+4
source share
2 answers

This should do the trick:

  • Delete files from .gitignore
  • Delete files with git rm (backup if you need) and run
  • Add the files to .gitignore again and run

Remember that you will probably have to do this for each branch, either manually or by pulling for commits from the main branch.

+3
source

I am not an expert in GIT, but it looks like you copied your point files before adding them to gitignore and before splitting up. This is how I solve these problems (maybe the best way to do this).

I copy the files outside the git repository, then run git rm <files> to remove the files from the repo, add the appropriate entries to gitignore, and then copy the files back to the project.

+1
source

Source: https://habr.com/ru/post/1312773/


All Articles