Restore Git-tracked executable file modes without restoring file contents.
Project description
git-restore-filemode
git-restore-filemode is a simple Git extension command that restores only Git's
tracked executable bit for regular files. It follows the destination/source
defaults of git restore, but it never restores file contents.
curl -fsSL https://raw.githubusercontent.com/yonathan-ashebir/git-restore-filemode/main/install.sh | bash
Examples
Restore working tree file modes from the index:
git restore-filemode -- script.sh
Restore staged file modes from HEAD:
git restore-filemode --staged -- script.sh
Restore both the index and working tree from a specific commit:
git restore-filemode --source=HEAD~1 --staged --worktree -- bin/
Supported options
-s,--source <tree-ish>: restore file modes from a tree-ish.-S,--staged: restore the index.-W,--worktree: restore the working tree.--ignore-unmerged: skip unmerged index entries when restoring from the index.--pathspec-from-file <file>: read pathspecs from a file, or-for stdin.--pathspec-file-nul: split--pathspec-from-fileinput on NUL bytes.-q,--quiet: suppress non-fatal messages.
Default source selection matches git restore:
- Working tree restore defaults to the index.
- Staged restore defaults to
HEAD. --sourceoverrides the default source.
Install
Bash script
curl -fsSL https://raw.githubusercontent.com/yonathan-ashebir/git-restore-filemode/main/install.sh | bash
Attempts system dependent global (system) installation path, falling back to user. Accepts --user and --system flags to force use either. Downloads compatible binary when available, building from source otherwise (requires cargo/rust)
Python
uv tool install git-restore-filemode
pip install --user git-restore-filemode
The Python package installs a small launcher named git-restore-filemode. On
first run it downloads the matching release executable into a per-user cache, or
falls back to Cargo when Rust is installed.
Node
npm install -g git-restore-filemode
pnpm add -g git-restore-filemode
bun install -g git-restore-filemode
The npm package follows the same release-download-first behavior and keeps the native executable inside the installed package.
Cargo
cargo install --path .
After this package is published to crates.io, the direct install command will be:
cargo install git-restore-filemode
Notes
Only regular Git blobs with modes 100644 and 100755 are restorable. Symlinks,
submodules, missing working tree files, and non-regular paths are not changed.
Registry metadata for PyPI and npm is included, but publishing those packages is intentionally left for a later release step.
Release Targets
- Linux x64 static:
x86_64-unknown-linux - Linux ARM64 static:
aarch64-unknown-linux - macOS Intel:
x86_64-apple-darwin - macOS Apple Silicon:
aarch64-apple-darwin - Windows x64:
x86_64-pc-windows-msvc - Windows ARM64:
aarch64-pc-windows-msvc
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file git_restore_filemode-0.1.0.tar.gz.
File metadata
- Download URL: git_restore_filemode-0.1.0.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e994be942093fc73b05753674c727742c80f51274d06d3d4cd378eb1cdc19c3
|
|
| MD5 |
b8dbe839d971b4af0667cffc32530b27
|
|
| BLAKE2b-256 |
e23573e51f19a00edb5e83a0b5b745bd7f5132654d58bfa289c5910c245fc74b
|
Provenance
The following attestation bundles were made for git_restore_filemode-0.1.0.tar.gz:
Publisher:
release.yml on yonathan-ashebir/git-restore-filemode
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
git_restore_filemode-0.1.0.tar.gz -
Subject digest:
3e994be942093fc73b05753674c727742c80f51274d06d3d4cd378eb1cdc19c3 - Sigstore transparency entry: 2256353193
- Sigstore integration time:
-
Permalink:
yonathan-ashebir/git-restore-filemode@3fd84dce4bf088f011f7e3111dc7ca54b81589a9 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/yonathan-ashebir
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3fd84dce4bf088f011f7e3111dc7ca54b81589a9 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file git_restore_filemode-0.1.0-py3-none-any.whl.
File metadata
- Download URL: git_restore_filemode-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
752b472829bb9d449a51e944ed8ee967f87f746820c04f4c2df4b74b82add090
|
|
| MD5 |
c4ce8b690b29943e4787aea7867bcab2
|
|
| BLAKE2b-256 |
efc50d2b7b4856fd4beb13083bec4e2d1c5602be38cf63475888e1ba60bebc29
|
Provenance
The following attestation bundles were made for git_restore_filemode-0.1.0-py3-none-any.whl:
Publisher:
release.yml on yonathan-ashebir/git-restore-filemode
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
git_restore_filemode-0.1.0-py3-none-any.whl -
Subject digest:
752b472829bb9d449a51e944ed8ee967f87f746820c04f4c2df4b74b82add090 - Sigstore transparency entry: 2256353200
- Sigstore integration time:
-
Permalink:
yonathan-ashebir/git-restore-filemode@3fd84dce4bf088f011f7e3111dc7ca54b81589a9 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/yonathan-ashebir
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3fd84dce4bf088f011f7e3111dc7ca54b81589a9 -
Trigger Event:
workflow_dispatch
-
Statement type: