Samstag, 19. November 2011

Git for stata

I use stata on a remote terminal server. This makes creating graphics fast, but how do I include them in the paper that I am writting locally in Word?
Well, I use git:

after having created the graphics in my working directory on the server i type "git" on the stata prompt. This checks in all the changes to my do files and all newly created grahpics.
In my client I then use "git pull [server] master"  to get the changes. Git is faster then normal file transfer AND it versions all the files.
The git function in stata I use is the following:



capture program drop git
program define git
! D:\kutsam\git\silentsync.bat `1'
forvalues r=1/100 {
        local val=r(o`r')
        if (length("`val'")>1){
        di `"`val'"'
        }
}
end



The silentsync.bat is:


set gitdir=d:\kutsam\git
set path=%gitdir%\cmd;%path%

rem Do not use "echo off" to not affect any child calls.
setlocal
rem Get the abolute path to the current directory, which is assumed to be the
rem Git installation root.
for /F "delims=" %%I in ("%~dp0") do @set git_install_root=%%~fI
set PATH=%git_install_root%\bin;%git_install_root%\mingw\bin;%git_install_root%\cmd;%PATH%

if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH%
if not exist "%HOME%" @set HOME=%USERPROFILE%

set PLINK_PROTOCOL=ssh
cd %HOME%



k:
cd k:\git\da
git add *
git commit -a -m "."
git pull jo master
git pull leontief master

cd d:\kutsam\gitlokal
d:
git add *
git commit -a -m "."
git pull luxor master

k:
%1

Keine Kommentare:

Kommentar veröffentlichen