Skip to main content

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-file input 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.
  • --source overrides 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

git_restore_filemode-0.1.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

git_restore_filemode-0.1.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

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

Hashes for git_restore_filemode-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3e994be942093fc73b05753674c727742c80f51274d06d3d4cd378eb1cdc19c3
MD5 b8dbe839d971b4af0667cffc32530b27
BLAKE2b-256 e23573e51f19a00edb5e83a0b5b745bd7f5132654d58bfa289c5910c245fc74b

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file git_restore_filemode-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for git_restore_filemode-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 752b472829bb9d449a51e944ed8ee967f87f746820c04f4c2df4b74b82add090
MD5 c4ce8b690b29943e4787aea7867bcab2
BLAKE2b-256 efc50d2b7b4856fd4beb13083bec4e2d1c5602be38cf63475888e1ba60bebc29

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page