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'"'

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.
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%

cd %HOME%

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

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


Dienstag, 15. November 2011

Git for economists

If you have not heard of version control systems you have either never programmed, or you are missing out on a really helpful tool.

 A version control system remembers all the different versions of a project. If you have ever programmed a STATA or R script you have run into the situation where somethin does not work any more that did work... yesterday.

A really nice version control system is GIT.   I have switched over from Subversion today, after having watched this video of linus torvals

Git works without a central repository, so I have my complete code base with me- -not matter what device I work on.