gitless icon indicating copy to clipboard operation
gitless copied to clipboard

track doesn't override .gitignore

Open kevinclevenger opened this issue 5 years ago • 2 comments

I have a repository with a large number of files, but I only want to track some of them. I add "/*" to .gitignore and then try to add a tracked file. I get:

$ gl track xyz ✘ File xyz is ignored. Edit the .gitignore file to stop ignoring file xyz

I'm more familiar with mercurial and it will override ignore this way. Is this possible, or should it be possible, with gitless?

kevinclevenger avatar Jan 13 '20 23:01 kevinclevenger

I don't think we should silently track the file because wanting to track an ignored file is most likely a user error. We can prompt the user to confirm that they want to track an ignored file, but I think that having a file that is both tracked and ignored is a bit confusing.

I am inclined to leave the behavior as it is now. Especially because you can negate a pattern in your gitignore to include files that are excluded by a previous pattern. In your example, you can add!xyz to the .gitignore file. What we can do is add a hint to the error message about a file being ignored that says "add !xyz to the .gitignore file to stop ignoring file xyz"

spderosso avatar Jan 16 '20 02:01 spderosso

FWIW git already does this with 'git add -f|--force'. Replicating that feature would be appropriate.

kevinclevenger avatar Jan 16 '20 05:01 kevinclevenger