The correct solution
Why not commit the changes? Git is a distributed system, so you might commit your changes on a throw-away branch or on a "stable" branch, then tag the commit and rewind the branch to where it was at before the commit—thus having the branches undisturbed and the commit tagged. You might even go for detached HEAD
and record the new commit there, then push it to the repo in which the tests are to be run.
I would recommend you to research these possibilities and convince your management this is the way to go: there's no need to touch the branch on which the delivered product is maintained to do testing.
If the machines with these repositories are not easily connected, and thus why you need to use tarballs, consider using git bundle
which has been implemented precisely for the means of transferring Git commits over the sneakernet.
With it, your workflow would be like this:
In the main repo (say, we're on the "master" branch):
git checkout -b testing
...
git commit ...
...
git bundle create /tmp/testing.bundle master..testing
Transfer /tmp/testing.bundle
to the target machine.
In the target repo:
git pull /tmp/testing.bundle testing
Or whatever is better fit, like, say
git fetch /tmp/testing.bundle +testing:testing
git checkout testing
The fallback solutuion
Anyway, if you have to live with this situation, do what @poke suggested: maintain the repository at the testing location, and when you receive another tarball, unroll it over the work tree of that repository and then run
git add --all
To cite the manual on --add
:
-A
--all
Like -u
, but match against files in the working tree in addition to the index. That means that it will find new files as well as staging modified content and removing files that are no longer in the working tree.
Hence basically it will only add to the index files which were modified.
One potential problem though is deletions: the files which are missing in the tarball compared to the work tree won't somehow be deleted automatically.