# Gitea post-recieve hook to push repo

**URL:** <https://forum.gitea.com/t/gitea-post-recieve-hook-to-push-repo/431>\
**Category:** Install/Maintain/Configure\
**Created:** [July 16, 2018, 4:34pm UTC](https://forum.gitea.com/t/gitea-post-recieve-hook-to-push-repo/431 "2018-07-16T16:34:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mxkle](https://avatars.discourse-cdn.com/v4/letter/m/b2d939/32.png) [@mxkle](https://forum.gitea.com/u/mxkle)\
**Post date:** [July 16, 2018, 4:34pm UTC](https://forum.gitea.com/t/gitea-post-recieve-hook-to-push-repo/431/1 "2018-07-16T16:34:25Z")

</div>

Hi everyone, happy gitea user here 🙂

I want to push a repo from my gitea server to a diffrent remote git server (gitlab).

So i created a post-recieve hook for the repository under repository -\> settings -\> git hooks -\> post-recieve

```
 #!/bin/bash
while read oldrev newrev ref
do
     if [[$ref =~ .*/master$]];
     then
         echo "master ref. push blog to gitlab.. " 
         git push gitlab master
     else
         echo "not on master branch.. "
     fi
done

```

Everytime i push code to my gitea server now, i get the following response:

```
remote: master ref. push blog to gitlab.. 
remote: fatal: 'gitlab' does not appear to be a git repository
remote: fatal: Could not read from remote repository.
remote: 
remote: Please make sure you have the correct access rights
remote: and the repository exists.

```

I have created a ssh-keypair for the git user (the user running gitea) and placed it in ~/.ssh  
Also i’ve pasted the public key of the git user into my gitlab account under settings -\> SSH Keys.  
Using gitea version 0549762 with docker.

Is there something iam missing? Is my post-recieve hook wrong?

Any help appreciated! 🙂

Thanks in advance and have a nice day.

---

<div class="post-metadata">

**Author:** ![anon74399538](https://avatars.discourse-cdn.com/v4/letter/a/c6cbf5/32.png) [@anon74399538](https://forum.gitea.com/u/anon74399538)\
**Post date:** [July 16, 2018, 5:02pm UTC](https://forum.gitea.com/t/gitea-post-recieve-hook-to-push-repo/431/2 "2018-07-16T17:02:25Z")

</div>

Push mirroring was made a CE feature in GitLab [two months ago](https://gitlab.com/gitlab-org/gitlab-ce/issues/42099) so it should be possible. According to the error `gitlab` is not a valid remote. Have you reached out to GitLab for support? If they supported the kind of mirroring Gitea does you wouldn’t be having this problem.

---

<div class="post-metadata">

**Author:** ![mxkle](https://avatars.discourse-cdn.com/v4/letter/m/b2d939/32.png) [@mxkle](https://forum.gitea.com/u/mxkle)\
**Post date:** [July 16, 2018, 5:09pm UTC](https://forum.gitea.com/t/gitea-post-recieve-hook-to-push-repo/431/3 "2018-07-16T17:09:36Z")

</div>

Cant use the feature of gitlab because my gitea server is not reachable from the outside. Its just an local docker container.

Ive also addded gitlab as a remote with:  
`git remote add git@gitlab.com:gitlab_user/repo.git`  
but i still get the error.

I havent tried to contact the gitlab support, wanted to make sure i dont have any dumb problems on my side with gitea.

Thanks for your reply balibebas 🙂

---

<div class="post-metadata">

**Author:** ![anon74399538](https://avatars.discourse-cdn.com/v4/letter/a/c6cbf5/32.png) [@anon74399538](https://forum.gitea.com/u/anon74399538)\
**Post date:** [July 16, 2018, 5:11pm UTC](https://forum.gitea.com/t/gitea-post-recieve-hook-to-push-repo/431/4 "2018-07-16T17:11:47Z")

</div>

Are you able to push up from a terminal inside your container manually?

---

<div class="post-metadata">

**Author:** ![mxkle](https://avatars.discourse-cdn.com/v4/letter/m/b2d939/32.png) [@mxkle](https://forum.gitea.com/u/mxkle)\
**Post date:** [July 16, 2018, 5:18pm UTC](https://forum.gitea.com/t/gitea-post-recieve-hook-to-push-repo/431/5 "2018-07-16T17:18:49Z")

</div>

Not exactly sure where i find the repo to try a manual push.  
But i just created a test-repo on gitlab, pulled it inside the container and pushed it after a minor change again to gitlab.

I had to configure git user credentials  
git config --global user.name “John Doe”  
git config --global user.email [johndoe@example.com](mailto:johndoe@example.com)

maybe i have to add this to the repo i want to push with the post-recieve hook?

---

<div class="post-metadata">

**Author:** ![anon74399538](https://avatars.discourse-cdn.com/v4/letter/a/c6cbf5/32.png) [@anon74399538](https://forum.gitea.com/u/anon74399538)\
**Post date:** [July 16, 2018, 5:22pm UTC](https://forum.gitea.com/t/gitea-post-recieve-hook-to-push-repo/431/6 "2018-07-16T17:22:40Z")

</div>

I’m not 100% sure as I haven’t tried this myself, but perhaps this will help:

> <https://stackoverflow.com/questions/21962872/how-to-create-a-gitlab-webhook-to-update-a-mirror-repo-on-github/21998477#21998477>

According to Gitea docs [looks like](https://docs.gitea.io/en-us/backup-and-restore/) git repos are stored in `custom/git`. Since your using Docker check your Gitea [volume](https://docs.docker.com/storage/volumes/) for the precise location. That should help get you out of the [black box](https://en.wikipedia.org/wiki/Black_box) it sounds like your in so you can debug properly.

---

<div class="post-metadata">

**Author:** ![mxkle](https://avatars.discourse-cdn.com/v4/letter/m/b2d939/32.png) [@mxkle](https://forum.gitea.com/u/mxkle)\
**Post date:** [July 16, 2018, 5:44pm UTC](https://forum.gitea.com/t/gitea-post-recieve-hook-to-push-repo/431/7 "2018-07-16T17:44:09Z")

</div>

This helped me. Never saw that there are “deploy keys”, i think i have to use thoose instead of just general ssh keys i added before.

I followed the instructions, now i get the following error:

```
remote: master ref. push blog to gitlab.. 
remote: Host key verification failed.
remote: fatal: Could not read from remote repository.
remote: 
remote: Please make sure you have the correct access rights
remote: and the repository exists.

```

feels like iam getting closer… thanks alot balibebas! 🙂

iam going to test more around and test my google skills again … this project is getting way more complicated that i acutally wanted 😕

---

<div class="post-metadata">

**Author:** ![anon74399538](https://avatars.discourse-cdn.com/v4/letter/a/c6cbf5/32.png) [@anon74399538](https://forum.gitea.com/u/anon74399538)\
**Post date:** [July 16, 2018, 6:07pm UTC](https://forum.gitea.com/t/gitea-post-recieve-hook-to-push-repo/431/8 "2018-07-16T18:07:26Z")

</div>

Glad to hear you’re making measured progress. If Google doesn’t deliver why not try DuckDuckGo after a small break and I bet you’ll get it. You’re teaching me things I wanted to know but wrote off before I started. Cheers.
