Skip to main content
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.5k
  • 205
  • 1.8k
  • 2.3k
Source Link

Passing a git command as an argument

I'm trying to automate some tedious parts of a student job I'm working on.

Basically, the goal is to clone a bunch of git repositories (which I already have working), then run the same git checkout on all of them. Each time, I'm given something like this:

`git rev-list -n 1 --before="2016-04-29 23:59" master`

to feed to git checkout. I'd like to pass this entire thing into my script so that it can do the checkouts for me. Currently, my script is

#!/bin/bash

echo $1

(It was initially more complex, but I've since commented everything else out so I can focus on this input.)

When I try to run the script:

./RepoScan `git rev-list -n 1 --before="2016-04-29 23:59" master`

I get the following error:

fatal: Not a git repository (or any of the parent directories): .git

followed by a newline. I assume this means that git rev-list is trying to run, rather than being passed to RepoScan. Is there a way to package it so that it doesn't run when entered as an argument, but can still be run by the script?

(Also, I'm using OSX, if that matters.)