A chmod-like interface for changing file permissions in Git repositories on Windows.
npm install -g ghmodghmod <mode> <file> [file2 file3 ...] [git-options]mode: Mode can be either:- Octal mode (e.g., 755)
- Symbolic mode: +x (make executable) or -x (make non-executable)
file: Path to file(s) to modifygit-options: Any additional options will be passed togit update-index
-v, --verbose: Show verbose output-h, --help: Show help message
Make a file executable (using octal mode):
ghmod 755 script.shMake a file executable (using symbolic mode):
ghmod +x script.shMake a file non-executable (using symbolic mode):
ghmod -x script.shMake a file non-executable (using octal mode):
ghmod 644 script.shMake multiple files executable:
ghmod +x script1.sh script2.shAdd a file to Git index and make it executable:
ghmod +x script.sh --addForce update and refresh the index:
ghmod +x script.sh --force --refreshYou can also use ghmod programmatically in your Node.js projects:
import { setFileMode, setFileModes } from 'ghmod';
// Change mode of a single file (using octal mode)
setFileMode('script.sh', '755');
// Change mode of a single file (using symbolic mode)
setFileMode('script.sh', '+x');
// Change mode of multiple files
setFileModes(['script1.sh', 'script2.sh'], '+x');
// With options
setFileMode('script.sh', '+x', {
verbose: true,
gitOptions: ['--add', '--force']
});ghmod translates Unix-style chmod commands into Git index commands. It uses git update-index --chmod to modify the executable bit of files in the Git repository.
- Mode
755or+x(rwxr-xr-x) sets the file as executable - Mode
644or-x(rw-r--r--) sets the file as non-executable
Any additional options passed to ghmod will be forwarded to the underlying git update-index command, allowing you to use all Git options directly.
MIT