0

I just installed a Gitlab instance on my LAN.

I want to use it as the central repository for a Drupal dev->test->prod staging setup.

So, 1st step, I want to push my local "dev" workspace to the Gitlab repo.

Following instructions at Gitlab docs, I try

cd ./drupal8
git remote add origin https://gitlab.example.com/user1/drupal8-test.git

But that fails and returns

fatal: remote origin already exists.

Checking in the drupal dir

cd ./drupal8
git remote -v
    composer        https://github.com/drupal-composer/drupal-project.git (fetch)
    composer        https://github.com/drupal-composer/drupal-project.git (push)
    origin  https://github.com/drupal-composer/drupal-project.git (fetch)
    origin  [email protected]:drupal-composer/drupal-project.git (push)

I want to be able to push to the Gitlab repo, but I still obviously want composer etc to work in my dev env.

What's the right setup & workflow for using Drupal with a central Gitlab repo, making sure that I keep the ability to manage my site in 'dev' with composer?

4
  • "fatal: remote origin already exists." That is how git works. You have to remove a remote before trying to add one with the same name.
    – cilefen
    Jun 29, 2016 at 19:24
  • That's not what I asked.
    – user58258
    Jun 29, 2016 at 19:32
  • You did not ask that, but the question cannot be answered without an understanding of why git remote add did not work for you. That is why I made it a comment.
    – cilefen
    Jun 29, 2016 at 19:36
  • This issue is slightly related and may interest you: drupal.org/node/2737773
    – cilefen
    Jun 29, 2016 at 19:45

1 Answer 1

3

Usually, people set up a remote named "upstream" for the source, in this case it would be https://github.com/drupal-composer/drupal-project.git. Remote "origin" should be the git URL of your Gitlab repo. So for you, here is a sample workflow:

The setup:

git remote rm origin
git remote rm composer
git remote add composer https://github.com/drupal-composer/drupal-project.git
git remote add origin https://gitlab.example.com/user1/drupal8-test.git

The result:

$ git remote -v
composer    https://github.com/drupal-composer/drupal-project.git (fetch)
composer    https://github.com/drupal-composer/drupal-project.git (push)
origin  https://gitlab.example.com/user1/drupal8-test.git (fetch)
origin  https://gitlab.example.com/user1/drupal8-test.git (push)

Get upstream files:

git fetch composer
git merge composer/8.x

Adding your own files:

touch myfile.txt
echo "hello world" > myfile.txt
git add foo.txt
git commit -m "Added my file."
git push origin master

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.