Skip to content

balaianu/git-diff-archive

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

git-diff-archive

A lightweight Git plugin that exports only the changed files between two commits into a neat archive — complete with a deleted-files.txt manifest.


💡 Why this exists

Some projects still live in the past — no CI/CD, no Git on the destination server, maybe even FTP deployments. But you still want a Git-based workflow and a painless way to ship only what changed.

That’s where this tool fits: It finds everything that changed between two commits (except deletions), archives it, and gives you a list of deleted files — so you can quickly update your production codebase without hunting through diffs manually.

Disclaimer: Yes, it’s a workaround. Yes, you should upgrade your infrastructure. But until that glorious day — this keeps you sane.


🧱 Features

  • 🔹 Exports added and modified files between any two commits
  • 🔹 Skips deletions automatically
  • 🔹 Generates a deleted-files.txt manifest and includes it in the archive
  • 🔹 Supports both .zip and .tar formats
  • 🔹 Automatically appends timestamps to archive filenames
  • 🔹 Optional --stamp adds short commit hashes to filenames
  • 🔹 Fully NUL-safe (handles filenames with spaces or special chars)
  • 🔹 Works as a regular Git subcommand: git diff-archive

⚙️ Installation

git clone https://github.com/balaianu/git-diff-archive.git
cd git-diff-archive
make install

This installs the git-diff-archive executable to ~/bin, making it available for your current user (no sudo needed).

To uninstall:

cd git-diff-archive
make uninstall

🚀 Usage

From inside any Git repository:

git diff-archive [options] [<from_commit> [<to_commit>]]

Default behavior

If you don’t specify commits:

  • from_commit defaults to HEAD^1
  • to_commit defaults to HEAD

The archive will be created in your home folder (~/) as projectname_YYYY-MM-DD_HH-MM-SS.zip


🧬 Options

Flag Description
-d, --destination Path to folder where the archive will be saved (default: ~)
-n, --name Custom archive name (default: current folder name)
-f, --format Archive format: zip or tar (default: zip)
-s, --stamp Append short commit hashes to the archive name
-v, --version Display current plugin version
-h, --help Show usage information

🧪 Examples

Export changes between HEAD and an older commit:

git diff-archive 702b3f

Export changes between two specific commits:

git diff-archive v1.0.0 v1.1.0

Save output as a .tar archive:

git diff-archive --format tar

Change destination and name:

git diff-archive -d ~/Desktop -n release_patch

Add commit hashes to the filename:

git diff-archive --stamp

Show help or version:

git diff-archive -h
git diff-archive -v

📦 Output Example

Running:

git diff-archive v1.0.0 v1.1.0 --stamp

Produces something like:

~/myproject_v1.0.0_v1.1.0_2025-10-28_16-45-12.zip

Contents:

src/
 ├─ api/
 │   └─ endpoints.js
 ├─ main.py
 └─ utils/helpers.py
deleted-files.txt

deleted-files.txt will list all paths removed between the two commits.


🛠 Known Limitations

  • Submodules are not archived (currently skipped)
  • Binary files are included as-is (no diff filtering)
  • Deterministic archives (fixed timestamps) not yet implemented
  • Destination path must exist before running

🐞 Issues & Requests

Found a bug? Have an idea? Open an issue or feature request on GitHub — ideally with:

  • The command you ran
  • The Git version you’re using
  • The type of archive (zip or tar)
  • Expected vs actual behavior

I built this for personal use, but I’ll try to fix bugs or merge useful improvements when time allows.


🤝 Contributing

Pull requests are welcome!

Type Target branch
🐛 Bug fixes master
✨ Enhancements / Features develop

Make sure your changes are POSIX-compliant and keep the script minimal and portable.


📾 License

GPL-3.0 — see the LICENSE file for details.


🖯 TL;DR

“A tiny Git plugin for people who still deploy like it’s 2009 — but with 2025-level sanity.”

About

Git plugin for exporting the changed files between the current HEAD and an older commit as an archive.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages