git get only list of the last i.e. 2 commit – Education Career Blog

I develope on Windows at home and send my changes to the customer. Customer do not want to have any SCM installed, so I need to send files I’ve changed from last iteration.
Currently I’m using Subversion with some kind of the automation by self-written batch, that is a mix of windows and GNU/unix utilities. The script looks into the given revisions, list what files are changed, removes duplication and get at the end a file of list.

@echo off
if (%3) == () goto usage
set TO_REVISION=HEAD
set PUSHNAME=%3-%1

svn log -v -q -r %2 %3 |  sed "s/^ ^t*AM \/:alnum:_*\/:alnum:_*\/\(.*\.:alnum:_*\)/tar --append --file=%PUSHNAME%.tar \1/" | sed "s/ (.*//g" | sort | uniq | grep -v "config.xml" >> %PUSHNAME%.bat
IF ERRORLEVEL 1 goto error
echo bzip2 %PUSHNAME%.tar>> %PUSHNAME%.bat
echo :: SVN REVISIONS :: %2>> %PUSHNAME%.bat
echo ... %PUSHNAME%.bat generated.
goto done

:usage
echo USAGE: %~nx0 push-file-name from:to-revision relative-or-absolute-path
echo See svn log -v -q -r REV to view repository log.
goto done

:error
echo ERROR! Check (if exists) output file %PUSHNAME%.bat
goto done

:done

The batch is not perfect but for me is OK.
Now i decide to move to the Git. I’ve converted the subversion repository to the Git repo. But show stopper to me I cannot find the replace command for svn -v -q -r log in Git manual 🙁
I’m sure it should be, but after a days of searching I’d like to ask about help more experienced Git-Gurus.

Thank in advance for your minutes spent for my problem,

Oleg

,

I guess you’re trying to get a list of files changed since some commit:

git diff-index <commit> --name-only

Will list all files changed since <commit> and only their names.

--name-only will save you trouble of sed’ing the name of files.
Using --name-status instead gets you more familiar looking

A   debian/control 
M   debian/rules

output.

,

git show HEAD HEAD^

This will show the last two commits of the current branch. For more options, see git show --help

Leave a Comment