Git protection removing raw .gitignored files?

I ask because git stash -u started deleting .gitignored eclipse configuration settings and did not save them in stash. I completely lost the project configuration. (Please let me know if this is incorrect or suspected behavior)

What other commands can delete unnecessary, ignored files?

What are some effective precautions to ensure that untrusted local files are not deleted?


Edit - Additional Information:

git-stash

Use -all instead of -u if you want to save your .gitignored files.

[- and | --include-untracked]

If the -include-untracked option is used, all raw files are also saved and then cleaned up with git clean, leaving the working directory in a very clean state. If the -all option is used instead, ignored files will be hidden and cleaned in addition to files without a trace.

+4
source share
1 answer

What are some effective precautions to ensure that unresponsive local files are not deleted?

Do not use commands that delete files :-).

Seriously: there is no special protection in git for irreproducible files, but git usually tries very hard not to lose any data unless you explicitly report it.

Even the most dangerous commands (for example, git reset --hard , git checkout -- file ) will not touch unaffected files. The only dangerous commands are (AFAIK):

  • git stash -u (as you found out)
  • git clean

In addition, I found that it is better to never have valuable data in files without a trace. If this is important, it needs to be checked. Only ejected data and generated files should be .gitignored.

Regarding the configuration of Eclipse: perhaps it is best to have some kind of tool for its auto-generation (or Eclipse generates it yourself through detection). Then you can safely .gitignore it and re-create it if lost.

+5
source

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


All Articles