This happens almost every time I init a new repo.
-
Start a new project. Create a bunch of new files.
-
git init -
git add . -
Oh shoot, there’s some IDE/build cruft I need to ignore.
-
echo ".scons-nodecount" > .gitignore -
Dammit, .gitignore doesn’t see it because this file has already been added.
-
git reset .scons-nodecount -
Dammit, git reset doesn’t work because there’s no commits yet.
… not sure what to do here, so …
-
Start over:
rm -rf .git
— edit —
How do I remove a file from the index on a fresh repo? git reset is what I’d traditionally do, but it seems like this isn’t allowed if there are no prior commits.
I do the same thing all the time. Try
git rm --cached .scons-nodecount. This will instruct Git to remove the file, but only from the index (--cached).