> The file is added to .gitignore

I'm not sure why this step of adding the name of an important file to the ignore list was added. To me, that sounds a bit backward. Usually, an important file would not be listed in the ignore file.


Would you be able to expand on the reason for the adding to the ignore list, and maybe what the file type was.


I suspect that unfortunately you have probably lost the file as git trusted the assertion that it was ignorable (which is a slight problem with Git's 'run with scissors' approach to certain things (like trusting the devs assertions, and assuming dumb mistakes are also trustable) .


The idea of 'precious' files keeps on repeating on the Git list (https://public-inbox.org/git/?q=precious+files), but there hasn't been any successful discussions.


On 02/11/2018 17:12, j...@tcs.ifi.lmu.de wrote:
Hi!

A checkout deleted a partially untracked file. Is there a way to recover the file? What did I do wrong?

The problem is likely due to .gitignore being checked in and changing across branches:

  * A stub for a new file is created, committed and pushed.
  * The file is added to .gitignore and "git rm --cached file" is
    executed since only I need that file.
  * Several commits to that branch happen. The file is heavily edited,
    but ignored by commits as expected.
  * After commit, pull and push; I checkout another (old) branch,
    which has not seen the commit that changes .gitignore
  * No changes, and I checkout the previous branch again. However, now
    my file seem irrevocably lost. The remote repository only contains
    the initial stub for this file, since it was only edited after it
    was being added to .gitignore

I usually advise my students to check-in their .gitignore file into the repository. Apparently this is a bad advice, since it now seemed to have led to a file loss. So what is the advice on this? Google turned up mixed advice there, but I could not find a reference to my problem described above.

Thanks for any advice,
 Steffen.
--
You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com <mailto:git-users+unsubscr...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Git for 
human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to