Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why am I committing a bunch of desktop.ini files despite .gitignore?

Tags:

git

git-commit

I don't understand what happened. I did

git add .
git commit

and suddenly I see a list of a bunch of desktop.ini files committed.

(I don't understand why previous commits did not get any of them, and what might have suddenly changed, but that's an aside)

So, I undid the commit

git reset --soft HEAD~1

Added a line to .gitignore:

./**/desktop.ini

And did another

git add .
git commit -m "test"

Still adding a bunch of desktop.ini. What am I doing wrong?

like image 333
Irina Rapoport Avatar asked May 11 '15 18:05

Irina Rapoport


People also ask

Why do I have multiple Desktop ini files?

The Desktop displayed by Windows when you start your computer or device is a combination of your user's Desktop and the Public Desktop folder. You see two desktop. ini files because two folders combine to create your Desktop, each with its own desktop. ini: one for your user account and one for the Public Desktop.

Why do I keep getting Desktop ini?

The Desktop. ini file is not visible by default as it's a protected operating system file. If it's suddenly appearing on your PC, you or another user have changed your folder settings to display hidden folders.

Why does .gitignore not work?

Some times, even if you haven't added some files to the repository, git seems to monitor them even after you add them to the . gitignore file. This is a caching issue that can occur and to fix it, you need to clear your cache.

Why do I see Desktop ini files everywhere?

ini keep appearing? The Desktop. ini file keeps appearing on your Windows 11/10 system mainly if the Hide protected operating system files option is unchecked in Folder Options. It is a system file that will be recreated automatically.


2 Answers

Just write this simpler thing into your .gitignore:

desktop.ini

You could also do

**/desktop.ini

but it has the same effect. See man gitignore for details.

Then do something like this to get files out of the index:

git reset --soft
git add .
like image 110
Thomas Avatar answered Dec 22 '22 00:12

Thomas


Your git reset --soft did not reset the index: you canceled the commit, but the files are still in the index (i.e. "added"). So, when you committed again, you got the same commit with the same files.

You wanted to to git reset --mixed (or omit --mixed which is the default anyway) to reset the index (but not the working tree).

like image 31
Matthieu Moy Avatar answered Dec 22 '22 01:12

Matthieu Moy