Run simple git operations (diff/log/add/commit/...) from outside the working directory.
Run git commands as if you were inside the working directory. This is useful when you want to avoid changing directory all the time when working with multiple repositories.
cd /tmp
rgit diff /home/d5ve/checkout1
rgit add /home/d5ve/checkout1/*.pl
rgit commit /home/d5ve/checkout1/rgit examines the commandline arguments, and tries to work out, then set the GIT_WORK_TREE and GIT_DIR environmental variables from any file paths.
Current version 0.05 - 2021-06-23
Now works for bare repositories.Version 0.04 - 2011-03-02
Now filters out obvious flags and comments from directory tests.
Now works when passed a commit message on the commandline.Version 0.02 - 2010-09-02
Now with some POD.rgit was written to address an issue I had when moving from SVN to git. I missed the ability to run operations on a checkout/repository from a directory outside it.
For example, of the following commands, only the SVN one works:
cd /tmp
svn diff /home/d5ve/svncheckout/*.pl # works as expected
git diff /home/d5ve/gitcheckout/*.pl # fails to workWithout doing any actual investigation, I think this may be because each directory in an SVN checkout has a .svn directory, so when you run a SVN command, which checkout is being referenced is gleaned from the file path. git, however, has only a .git directory at the very top of the checkout. This means that the only simple way to run git commands against a working directory is to move into the working directory (or any subdirectory of the working directory).
You can use the GIT_WORK_TREE and GIT_DIR environmental variables to tell git where the repository and .git directory are. rgit attempts to work out the correct value for these variables, then sets them before running the command.
All file paths are converted from relative to full.
Simply copy the rgit script to a directory in your $PATH.
This module requires these other modules and libraries:
File::Spec
File::Basename
rgit is free software. It comes without any warranty, to the extent permitted by applicable law.
rgit is released under the WTFPL Version 2.0 licence - http://sam.zoy.org/wtfpl/COPYING