Here's a way to avoid this vexing problem when you start a new project:
- Create the main directory for your new project.
- Run
git init
. - Now create a .gitignore file (even if it's empty).
- Commit your .gitignore file.
Git makes it really hard to do git reset
if you don't have any commits. If you create a tiny initial commit just for the sake of having one, after that you can git add -A
and git reset
as many times as you want in order to get everything right.
Another advantage of this method is that if you run into line-ending troubles later and need to refresh all your files, it's easy: Check out that initial commit; then check out your most recent commit again.
- Check out that initial commit. This will remove all your files.
- Then check out your most recent commit again. This will retrieve fresh copies of your files, using your current line-ending settings.