I want to ignore executable files that do not have an extension
For example:
gcc -o foo foo.c
I know I could add 'foo' to my .gitignore file, but if I decide to change the name of the executable I would need to update my .gitignore file...
I want to ignore executable files that do not have an extension
For example:
gcc -o foo foo.c
I know I could add 'foo' to my .gitignore file, but if I decide to change the name of the executable I would need to update my .gitignore file...
It's really going to be best for you to manually maintain the gitignore, probably. You could do this:
*
!*.*
to exclude everything, then include everything with a ".", but I suspect your directories don't have extensions. Currently tracked directories would still be tracked, of course, but if you added a new one, git-status
wouldn't see it, and you'd have to use add -f
to get it in.
It's probably not good to assume all extension-less files shouldn't be tracked, anyway. You may end up with some naturally - for example, README and INSTALL are pretty common. It's way worse to accidentally ignore a file than to have to modify the gitignore, too. Modifying the gitignore might take a few seconds, but it'll be obvious when you need to do it. If you accidentally ignore a file, you could easily not check it in and lose the work.
I usually handle this using makefile hacks. In my Makefile i have the name of the executable $(name) and then I do this:
#first rule
all: gitignoreadd ... more depends
... some commands ...
gitignoreadd:
grep -v "$(name)" .gitignore > temp
echo $(name) >> temp
mv temp .gitignore
gitignoreremove:
grep -v "$(name)" .gitignore > temp
mv temp .gitignore
Ant that rule can just be a dependency of the make somewhere appropriate. Then you usually have a 'make clean' rule as follows:
clean: gitignoreremove
rm *.o *.othergarbagefiles $(name)
And that should do the trick. It's a hack but it works for me. The only think is that you must run make clean before changing the name to automatically clean everything up.