Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1003945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:03:22+00:00 2026-05-16T08:03:22+00:00

Git has the very handy archive command which allows me to make a copy

  • 0

Git has the very handy archive command which allows me to make a copy of a particular commit in a .zip archive like so:

git archive -o ../latest.zip some-commit

This will contain the entire working tree for that commit. Usually I just need the changed files since a previous release. Currently I use this to get those files into a zip:

git diff --name-only previous-commit latest-commit | zip ../changes.zip -@

This will however zip files from my working copy, which may have uncommitted changes. Is there some way to get only the changed files as they were committed directly into a zip?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T08:03:23+00:00Added an answer on May 16, 2026 at 8:03 am

    git archive will accept paths as arguments. All you should need to do is:

    git archive -o ../latest.zip some-commit $(git diff --name-only earlier-commit some-commit)
    

    or if you have files with spaces (or other special characters) in them, use xargs:

    git diff --name-only earlier-commit some-commit | xargs -d'\n' git archive -o ../latest.zip some-commit
    

    If you don’t have xargs properly installed, you could cook up an alternative:

    #!/bin/bash
    
    IFS=$'\n'
    files=($(git diff --name-only earlier-commit some-commit))
    
    git archive -o ../latest.zip some-commit "${files[@]}"
    

    Written as a shell script, but should work as a one-liner too. Alternatively, change earlier-commit, some-commit, and ../latest.zip to $1 $2 and $3 and you’ve got yourself a reusable script.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My routine on git has always been very simple: git add -A git commit
I have a git repo which has a few branches - there's the master
my co-worker has just create a new branch in the git repository which we
I have machine1 with git repo client , which has branches master and fixes_v3
I am very happily using git-svn, though I noticed that git has a different
We have a git repository managed by gitosis under Ubuntu, which has worked well
I am using git for a large legacy project which has two branches -
My git repository has ~2,000 commits. For educational purposes, I have been playing around
Assume my git repository has the following structure: /.git /Project /Project/SubProject-0 /Project/SubProject-1 /Project/SubProject-2 and
I am using git along with git flow . Here git flow has a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.