Frage

I've got a local folder/directory/repo called /renders. When I ls -a this I get

➜  renders git:(master) ls -a

.git
corner_desk.jpg
multi-person_desk.jpg

Each of the two image files has had many revisions commited. All of the versions/revisions of the two image files need to be sent for review to someone who does not and will not use Git. So they can't browse the commit history. What is the most efficient way to create a new folder, from the Git repo folder, that can be sent to them (emailed, Dropboxed, whatevs)? When this newly generated folder is ls -a it should return something like

➜  renders ls -a

corner_desk_01.jpg
corner_desk_02.jpg
corner_desk_03.jpg
corner_desk_04.jpg
corner_desk_05.jpg
multi-person_desk_01.jpg
multi-person_desk_02.jpg
multi-person_desk_03.jpg
War es hilfreich?

Lösung

You can get git log to show you just the commits that actually changed a particular file, and you can use its "pretty" output formatting to spit commands to do anything you like. So with a bit of shell-variable munging added in,

git ls-files render | while read f; do 
    git log --pretty="git show %H:$f >${f%.*}_%at.${f##*.}" -- $f
done | less # sh -x

The above numbers the files with their modification timestamp rather than a serial number, if that's too much for your client then you can get the shell to serialize them for you with

git ls-files render | while read f; do 
    git log --reverse \
            --pretty="git show %H:$f >${f%.*}_\$((1000+++x)).${f##*.}" -- $f
done | less # sh -x

Andere Tipps

You could basically extract all the commit ID's which contain a particular image and then use git show to pull them out one at a time.

In the following sample script, I assume that you have a linear commit history, so git log will show every commit. Note that you will have to make modifications for your purposes, but this should give you the general idea.

#!/bin/bash

i=1
for c in `git log | grep commit | awk '{print $2}' ` ;
do
name=`printf "%2d" $i | tr -d ' '`
i=$(($i+1))
echo $name
git show $c:Foo > "/tmp/Foo$name"
done;

This question tells us that git show is safe for binary files.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top