# Git Metafile A simple tool for storing and restoring complete files metadata (mode, owner, group) in a git repository. It’s designed especially for versioning /etc. Metadata is tracked using the `.metafile` file, which is automatically updated and added to commits. This file is in TSV (tab-separated values) format to be easily readable and diffable. ***Sample .metafile*.** #%GIT-METAFILE 1 # .gitignore 100644 0 0 .metafile 100644 0 0 profile.d 40755 0 0 shadow 100640 0 42 # Installation ## On Alpine Linux If you’re using **Alpine Linux**, you can install [git-metafile](https://pkgs.alpinelinux.org/packages?name=git-metafile) package from the Alpine’s community repository: ``` sh apk add git-metafile ``` ## On Arch Linux If you’re using **Arch Linux**, you can install [git-metafile](https://aur.archlinux.org/packages/git-metafile) package from [AUR](https://aur.archlinux.org/): ``` sh yay -S git-metafile ``` Or use another AUR helper. ## Using cargo If you’re a **Rust developer**, you can build and install [git-metafile](https://crates.io/crates/git-metafile) from [crates.io](https://crates.io/) using `cargo`: ``` sh cargo install git-metafile ``` Note that the binary may be bigger than expected because it contains debug symbols. To remove debug symbols and therefore reduce the file size, run `strip` on the binary. ## Using pre-built binary If your package manager doesn’t provide git-metafile, you can use a pre-built binary. On Linux, you can choose either a statically linked \[1\] **(static)** binary that should work on every Linux system (distro), or, if you’re using a sufficient recent GNU/libc-based **(glibc)** distro (most major distros), a dynamically linked binary. > 🐧 **Linux (static)**: > [\[x86\_64\]](https://github.com/jirutka/git-metafile/releases/download/v0.2.3/git-metafile-0.2.3-x86_64-linux.tar.gz) > [\[aarch64\]](https://github.com/jirutka/git-metafile/releases/download/v0.2.3/git-metafile-0.2.3-aarch64-linux.tar.gz) > [\[armv7\]](https://github.com/jirutka/git-metafile/releases/download/v0.2.3/git-metafile-0.2.3-armv7-linux.tar.gz) > 🐧 **Linux (glibc)**:  > [\[x86\_64\]](https://github.com/jirutka/git-metafile/releases/download/v0.2.3/git-metafile-0.2.3-x86_64-linux-gnu.tar.gz) > [\[ppc64le\]](https://github.com/jirutka/git-metafile/releases/download/v0.2.3/git-metafile-0.2.3-powerpc64le-linux-gnu.tar.gz) > [\[riscv64gc\]](https://github.com/jirutka/git-metafile/releases/download/v0.2.3/git-metafile-0.2.3-riscv64gc-linux-gnu.tar.gz) >  **macOS**: > [\[x86\_64\]](https://github.com/jirutka/git-metafile/releases/download/v0.2.3/git-metafile-0.2.3-x86_64-apple-darwin.tar.gz) 1. Install git (use your system’s package manager). 2. Download and extract release tarball for your OS and CPU architecture (pick the right link from the list above): ``` sh curl -sSLO https://github.com/jirutka/git-metafile/releases/download/v0.2.3/git-metafile-0.2.3-x86_64-linux.tar.gz curl -sSL https://github.com/jirutka/git-metafile/releases/download/v0.2.3/checksums.txt | sha256sum -c --ignore-missing tar -xzf git-metafile-0.2.3-*.tar.gz ``` 3. Install `git-metafile` somewhere on your `PATH`, e.g. `/usr/local/bin`: ``` sh install -m 755 git-metafile-0.2.3-*/git-metafile /usr/local/bin/ ``` ## From source tarball 1. Install git (use your system’s package manager). 2. Download and unpack the tarball: ``` sh wget https://github.com/jirutka/git-metafile/archive/v0.2.3/git-metafile-0.2.3.tar.gz tar -xzf git-metafile-0.2.3.tar.gz cd git-metafile-0.2.3 ``` 3. Build git-metafile using cargo: ``` sh cargo build --release --locked ``` 4. Grab the binary from `target/release/git-metafile` and install it somewhere on your `PATH`, e.g. `/usr/local/bin`: ``` sh install -D -m755 target/release/git-metafile -t /usr/local/bin/ ``` # How to use To automatically record files attributes on every commit and restore them on every checkout, set up git hooks: ``` sh cat >> .git/hooks/pre-commit <> .git/hooks/post-checkout <