Indeed, it would be nice if
git-add
had a--mode
flag
git 2.9.x/2.10 (Q3 2016) actually will allow that (thanks to Edward Thomson):
git add --chmod=+x -- afile
git commit -m"Executable!"
That makes the all process quicker, and works even if core.filemode
is set to false.
See commit 4e55ed3 (31 May 2016) by Edward Thomson (ethomson
).
Helped-by: Johannes Schindelin (dscho
).
(Merged by Junio C Hamano -- gitster
-- in commit c8b080a, 06 Jul 2016)
add
: add--chmod=+x
/--chmod=-x
optionsThe executable bit will not be detected (and therefore will not be set) for paths in a repository with
core.filemode
set to false, though the users may still wish to add files as executable for compatibility with other users who do havecore.filemode
functionality.
For example, Windows users adding shell scripts may wish to add them as executable for compatibility with users on non-Windows.Although this can be done with a plumbing command (
git update-index --add --chmod=+x foo
), teaching thegit-add
command allows users to set a file executable with a command that they're already familiar with.