Gitlab Mirroring

Hi I’m trying to use Gitlab Mirroring to sync Gitlab and Glitch repositories.

Problem: uncommited changes appear after Gitlab Push.
Steps:

  1. Gitlab and Glitch repositories are fully synced. Then Gitlab pushes a commit (9e25230…) into my Glitch repo but changes aren’t applied.

  2. * git log* (Glitch console) shows the commit (9e25230....) is recieved. git log
    commit 9e25230b2f8dd6746bf1be4617a3dde50912316a
    Author: ros ......@mail.com
    Date: Wed Jan 8 13:30:44 2020 +0000
    Commit test 1

    $ git show 9e25230b2f8dd6746bf1be4617a3dde50912316a
    commit 9e25230b2f8dd6746bf1be4617a3dde50912316a
    Author: ros ......@mail.com
    Date: Wed Jan 8 13:30:44 2020 +0000
    Commit test 1
    diff --git a/testfile b/testfile
    new file mode 100644
    index 0000000…56a6051
    — /dev/null
    +++ b/testfile
    @@ -0,0 +1 @@
    +1
    \ No newline at end of file

  3. * git status* shows uncommited changes that try to undo commit (9e25230....) git status
    On branch testbranch
    Changes to be committed:
    (use “git reset HEAD …” to unstage)
    deleted: testfile

  4. Then I need to do git reset --hard (Glitch console) to reset uncommited changes.

Question: Why uncommited changes occur when it should be fast-forward merge? Maybe I do something wrong?

not supported (i thinks so?)

not supported because of Gitlab?

Hi @rosivanov, welcome to the Glitch support forums!

I tried setting up push mirroring from GitLab to Glitch, but was not able to reproduce what you’re seeing. Here’s what I did, so we can compare notes:

  1. Created a new project on GitLab, per the instructions you linked on GitLab mirroring.
  2. After the repository was imported to GitLab, I went to Settings > Repository, hit the “Expand” button next to “Mirroring repositories”, and set it up with Push mirror direction; I used https://<username-token>@api.glitch.com/git/<project-name> and left the password blank.
  3. I then cloned the project to my local machine, created a new branch called testbranch, and made a change to the README.md file; I committed and pushed that change back up to GitLab.
  4. Being somewhat impatient, I manually triggered the push mirroring to send this change back over to Glitch.
  5. I opened the console on my Glitch project and ran the following commands to see what happened, as well as to merge in my changes from GitLab and refresh the Glitch editor’s UI:
app@north-of-49:~ 18:28 
$ git status
On branch master
nothing to commit, working directory clean

app@north-of-49:~ 18:28 
$ git branch
* master
  testbranch

app@north-of-49:~ 18:28 
$ git diff master testbranch
diff --git a/README.md b/README.md
index cb1061b..27a7123 100644
--- a/README.md
+++ b/README.md
@@ -24,4 +24,4 @@ On the back-end,
 Made by [Glitch](https://glitch.com/)
 -------------------
 
-\ ゜o゜)ノ
+🎏🎉

app@north-of-49:~ 18:29 
$ git status
On branch master
nothing to commit, working directory clean

app@north-of-49:~ 18:29 
$ git merge testbranch
Updating 56e11db..4a5d01e
Fast-forward
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

app@north-of-49:~ 18:30 
$ refresh
restarting...

Everything there worked as I’d expected; could you tell me a little bit more about how you’re doing this? Are changes from GitLab happening on the master branch or a working branch? Are you working on the master branch or a working branch on Glitch?

2 Likes

Hi, @angelo thank you for your investigation, appreciate it! :slightly_smiling_face:
I was working on the testbranch on Glitch (not master). As you know git doesn’t allow to push to the current working branch, therefore, I’ve changed git config receive.denyCurrentBranch to ignor value in order to be able to push from Gitlab to the current working branch. Maybe it was the reason of my problem? :thinking:
Anyway, I’ve started a new project on Glitch with git config receive.denyCurrentBranch default value, staying on master branch, making pushes to the testbranch and it works as expected. :grinning:
Question: should I merge master with my working branch (testbranch) each time manually (in Glitch console) or is there a way to automate it?

Ah, interesting — thanks for the follow up information, @rosivanov!

Is it possible that you also had the Glitch editor open while GitLab pushed changes to your Glitch project? Because Glitch auto-commits to your project every so often, I can imagine that if you’re working in the same branch on Glitch as you’re pushing to (e.g., testbranch), you could end up in a state where the commits coming from GitLab are getting reverted by auto-commits from Glitch.

Whatever branch you have checked out on Glitch is what you’ll see if you visit the live app, so I like to keep Glitch on master and push changes to a different branch, then merge them in manually — to avoid anything accidentally breaking. You may be able to set up a git hook to automatically merge into master when changes are pushed to another branch, but I haven’t dug into that very deeply.

Hope this helps!

3 Likes

Hi, @angelo
I closed the Glitch editor each time. I was holding Glitch console opened only.
Git hooks look great, thank you! :grinning:

2 Likes