# using git-push to backup repo...strange behavior

3 messages from 2008-05-30 to 2008-05-30. Participants: davetron5000, Teemu Likonen, david@lang.hm.
Thread: https://gitlist.dev/t/13732

## davetron5000, 2008-05-30 12:42

Subject: using git-push to backup repo...strange behavior
Message-ID: <3a6159d2-e1ff-4aa8-bfeb-806af2bc82c8@8g2000hse.googlegroups.com>
URL: https://gitlist.dev/e/3a6159d2-e1ff-4aa8-bfeb-806af2bc82c8%408g2000hse.googlegroups.com

```
at least to me.

I have a git repo locally.  Want to essentially back it up on a remote
server using git.

First step was tar/gz the repo, scp it to my server and expand it.
Periodically throughout the day, I will do a

git push ssh://my.hostname.com/path/to/git/repo

There's a few issues:

1. Sometimes it doesn't work, saying a branch is "non fast forward".
--mirror or -f fixes this, but it seems wrong; I make no changes
remotely and clocks are in sync
2. --mirror doesn't like git stash, saying 'stash' is a "funny
refname"
3. On the remote side, I can find no way to update the working dir
with the changes other than git reset --hard.  Do I even need to do
this?  I'd like to be able to for automated builds/tests someday.
4. I made post-update executable, but it never runs (it echos a
message to a file)

I can't help feeling I'm doing everything wrong and just chancing on
things working under certain conditions.

Dave

```

## Teemu Likonen, 2008-05-30 12:58

Subject: hooks/post-update does not run
Message-ID: <20080530125814.GA8584@mithlond.arda.local>
URL: https://gitlist.dev/e/20080530125814.GA8584%40mithlond.arda.local
In-Reply-To: <3a6159d2-e1ff-4aa8-bfeb-806af2bc82c8@8g2000hse.googlegroups.com>

```
davetron5000 wrote (2008-05-30 05:42 -0700):

> There's a few issues:
[...]
> 4. I made post-update executable, but it never runs (it echos a
> message to a file)

I have experienced this too. I never got post-update to do anything
- even if the repository lies on the same computer and filesystem I'm
pushing from. I wrote about this issue two ago but it didn't get any
replies: 

http://thread.gmane.org/gmane.comp.version-control.git/82351

```

## david@lang.hm, 2008-05-30 13:15

Subject: Re: using git-push to backup repo...strange behavior
Message-ID: <alpine.DEB.1.10.0805300611230.4014@asgard.lang.hm>
URL: https://gitlist.dev/e/alpine.DEB.1.10.0805300611230.4014%40asgard.lang.hm
In-Reply-To: <3a6159d2-e1ff-4aa8-bfeb-806af2bc82c8@8g2000hse.googlegroups.com>

```
On Fri, 30 May 2008, davetron5000 wrote:

> 3. On the remote side, I can find no way to update the working dir
> with the changes other than git reset --hard.  Do I even need to do
> this?  I'd like to be able to for automated builds/tests someday.
> 4. I made post-update executable, but it never runs (it echos a
> message to a file)

I just went though this.

in the remote repo I make .git/hooks/post-receive executable, then edited 
it and made the script that it optionally calls excecutable, and 
uncommented it.

I then added git checkout -f  and ran into a problem that was answered 
this morning by Johan Herland so the final script is

#!/bin/sh
if [ "$GIT_DIR" = "." ]; then
         GIT_DIR=`pwd`
fi

/usr/share/doc/git-core/contrib/hooks/post-receive-email
cd ..
/usr/bin/git checkout -f

David Lang

```
