I am working on a C project which generates lots of binaries. I try to keep the source under source control. However, I would like the binaries to be ignored without having to add them to the gitignore file whenever I create a new one. This is a sandbox of sorts and so I create lots of new binaries as I try out new things. I could build all my binaries in a single directory or give them a suffix, but I dislike these reasons. Since GCC automatically sets the executable bit on the binaries it produces, can I use that flag to ignore them?
相关问题
- Why does recursive submodule update from github fa
- Extended message for commit via Visual Studio Code
- Emacs shell: save commit message
- Can I organize Git submodules in a flat hierarchy?
- Upload file > 25 MB on Github
相关文章
- 请教Git如何克隆本地库?
- GitHub:Enterprise post-receive hook
- Git Clone Fails: Server Certificate Verification F
- SSIS solution on GIT?
- Is there a version control system abstraction for
- ssh: Could not resolve hostname git: Name or servi
- Cannot commit changes with gitextensions
- git: retry if http request failed
Not directly, but you can use
find
to find programs with execute permissions:Run as needed to create new
.gitignore
entries. (Note that this is to be used with care; it will find executable shell scripts, which are source files, as well as executable binaries.)I recommend against this. What happens if you need to use a script in your build process or at runtime, but it's accidentally gitignored because it has the executable bit? This could especially create confusion if other people contribute to your project without knowing about the gitignore. You're best off manually adding files (or using a bin directory) to solve this problem.
That being said, gitignore does not seem to support mode-based file ignores, but you can automate the process of manually adding files that are executable.
If your
.gitignore
file can be overwritten:Run this to update your ignored files:
find -type f -executable | sed 's#^.##' > .gitignore
If your
.gitignore
file should be kept intact:.gitignore
should still work):git config core.excludesfile .auto_gitignore
find -type f -executable | sed 's#^.##' > .auto_gitignore
.auto_gitignore
if you want to share it with others, or add.auto_gitignore
to.git/info/exclude
if you don't. Note that if you do share it, your collaborators will also have to do step 1 individually.Note: If you get an error because your version of find doesn't support
-executable
, replace it with-perm /111
.