Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to download ONLY files changed in a commit/revision using git archive

Tags:

git

bitbucket

Using git archive commmand is it possible to download only the changed/affected files from a repository for a particular commit id ? Is it possible using the web interface @ bitbucket ?

like image 825
Shanthi Avatar asked Aug 22 '12 12:08

Shanthi


People also ask

What does git archive do?

Git archive is a helpful utility for creating distributable packages of git repositories. Git archive can target specific refs of a repository and only package the contents of that ref. Git archive has several output formats that can utilize added compression.

How does git store revision history?

Git stores the complete history of your files for a project in a special directory (a.k.a. a folder) called a repository, or repo. This repo is usually in a hidden folder called . git sitting next to your files.


1 Answers

List the files changed in a commit with git diff-tree and pass them to the command line of git archive.

git archive --format=zip --output=commit_files.zip <tree-ish> `git diff-tree --no-commit-id --name-only -r <tree-ish> | sed ':a;N;$!ba;s/\n/ /g'`
like image 102
Serg M Ten Avatar answered Sep 19 '22 19:09

Serg M Ten