A simple bash script to create zip archives of modified files between two git commits while preserving the original folder structure.
- Git repository (initialized and synchronized with GitHub)
- Bash shell
ziputility (usually pre-installed on most Linux/macOS systems)
Clone or add this tool to your project folder that is synchronized with your GitHub repository:
# Option 1: Clone the repository into your project
git clone https://github.com/your-username/git-changes-zipper.git
cd git-changes-zipper
# Option 2: Download just the script file
wget https://raw.githubusercontent.com/your-username/git-changes-zipper/main/zip-modified.sh
# or
curl -O https://raw.githubusercontent.com/your-username/git-changes-zipper/main/zip-modified.shGive executable permissions to the script:
sudo chmod +x zip-modified.shThe script compares two commits and creates a zip file containing all modified files between them.
./zip-modified.sh <start-commit-id> <end-commit-id> [--dry-run]start-commit-id: The starting commit hash (should be one commit before where you want to start checking)end-commit-id: The ending commit hash--dry-run(optional): Preview mode - shows what files would be zipped without creating the archive
Test what files would be included without creating a zip:
./zip-modified.sh abc123 def456 --dry-runOutput:
Files changed between abc123 and def456 (excluding specified files/dirs):
src/components/Header.js
src/styles/main.css
package.json
[Dry-run] Would zip these files while preserving folder structure.
Generate the actual zip file with modified files:
./zip-modified.sh abc123 def456Output:
Files changed between abc123 and def456 (excluding specified files/dirs):
src/components/Header.js
src/styles/main.css
package.json
Created zip archive: changes_abc123_to_def456_20241201_143052.zip
# View recent commits with short hashes
git log --oneline -10
# View detailed commit history
git log --graph --pretty=format:'%h - %an, %ar : %s'- Go to your repository on GitHub
- Click on "Commits" tab
- Copy the commit hash (first 7-8 characters are sufficient)
# See recent HEAD movements
git reflogThe script creates a zip file with the following naming convention:
changes_<start-commit>_to_<end-commit>_<timestamp>.zip
Example: changes_abc123_to_def456_20241201_143052.zip
The zip file maintains the original folder structure of your project, so extracted files will be in their correct relative paths.
The script automatically excludes the following files and directories:
public-old/directory and its contents.vscode/directory and its contents.cursor/directory and its contentschanges.sqlfile.gitignorefile
start-commit-id should be one commit before the actual starting point you want to check.
Example scenario:
- You want to see changes from commit
Bto commitD - Use commit
Aas the start-commit-id - Git diff will show: A → B → C → D (changes from A to D, which includes your desired B to D)
A (use this) → B (actual start) → C → D (end)
# Always run dry-run first to preview
./zip-modified.sh abc123 def456 --dry-run
# If satisfied with the preview, run actual command
./zip-modified.sh abc123 def456You don't need the full commit hash - first 7-8 characters are sufficient:
# Full hash (works)
./zip-modified.sh a1b2c3d4e5f6g7h8i9j0 x9y8z7w6v5u4t3s2r1q0
# Short hash (recommended)
./zip-modified.sh a1b2c3d x9y8z7wSolution: Ensure you're running the script from within a git repository:
git status # Verify you're in a git repoSolution: Verify the commit hash exists:
git log --oneline | grep xyz
# or
git show xyzSolution: Make sure the script has executable permissions:
ls -la zip-modified.sh # Check permissions
sudo chmod +x zip-modified.sh # Add execute permissionThis could mean:
- The commits are identical
- The start and end commits are in wrong order
- All changes are in excluded directories
[Add your license information here]
[Add contribution guidelines here]
Need help? Open an issue in this repository or contact [your-email@example.com]