Configure existing git
Asked by ITStacks:

Hello,

I'm facing some issues. We're using siteground as a hosting provider and they have an option to create a git repository. The problem is that they provide a 'git clone ssh:' path to clone, that I cannot use on the import option of bitbucket.

So, my workaround was this (that not sure if is correct)

1. clone the created repo locally

2. Create repo on bitbucket

3. Copy all files into the bitbucket master (except .git folder)

The problem Im facing is that the repo looses the connection to the live site (due that im using bitbucket repo instead of the created in siteground) so, I can't pull to live site.

Ive tried to create a pipeline connecting through ftp, but it tales more than 120m so it gives error and doesnt deploy.

I'm doing anything wrong here, or how can I connect the master repo to pull into live site?

We have a staging enviroment using plesk, that is working. On plesk we have a git extension where we can copy the 'clone' path of bitbucket and select the branch. The problem is that siteground/sitetools doesn't have that option/extension

Thank you!


Answers:
author: Theodora Boudale
body: Hi [@ITStacks](/t5/user/viewprofilepage/user-id/4292416) and welcome to the community.

I'm not sure I understand which of the following two you are trying to achieve:

1. Do you want to keep in sync the Bitbucket repo, with the Git repo hosted by SiteGround?  
2. Or do you want to be able to push the files from the Bitbucket repo to a remote server?

Allow me to say that I'm not really familiar with SiteGround, so I'm not sure what your set up is there.

You mentioned that you tried creating a Pipeline and use ftp but the deployment failed.

If you want to copy files to a remote server via Pipelines, we have certain [pipes](https://support.atlassian.com/bitbucket-cloud/docs/what-are-pipes/) that you can use in your bitbucket-pipelines.yml file for that purpose.

For example, if it is possible to connect to the remote server via SSH, you can set up SSH keys in Bitbucket Pipelines for this repo, as per:

* <https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/#Use-SSH-keys-in-Bitbucket-Pipelines>

then you can use one of these pipes to deploy:

* <https://bitbucket.org/product/features/pipelines/integrations?p=atlassian/scp-deploy>
* <https://bitbucket.org/product/features/pipelines/integrations?p=atlassian/rsync-deploy>

We also have a pipe for deploying via ftp, I'm not sure if you've been using this one, or if you're trying to deploy with git ftp commands?

* <https://bitbucket.org/product/features/pipelines/integrations?p=atlassian/ftp-deploy>

Regarding the Pipelines build that fails, can you see in the log of this build whether the deployment of files starts, or if the connection to your remote server is closing/timing out?

Kind regards,  
Theodora

comments: author: ITStacks
body: Hello Theodora!

Thank you for your reply, I've tested the rscync deploy and it worked well!

I need to exclude some files (like wp-config.php) from the whole workflow, I've tried using the pull request ignore/exlude but when I create and approve/merge the pull request, then the file is still updating with the changes

Is there a way to exclude files from the pipeline itself?

Thanks!


author: Theodora Boudale
body: Hi [@ITStacks](/t5/user/viewprofilepage/user-id/4292416) ,

Good to hear that the rsync deploy worked well!

Regarding excluding files, the PR exclude files option won't work here, this feature is only for excluding files from the PR diff.

In order to exclude files from deploy with this pipe, you can use the EXTRA_ARGS variable of the pipe. One example we have in our docs is the following:

```
script:
  - pipe: atlassian/rsync-deploy:0.4.4
    variables:
      USER: 'ec2-user'
      SERVER: '127.0.0.1'
      REMOTE_PATH: '/var/www/build/'
      LOCAL_PATH: 'build'
      DEBUG: 'true'
      EXTRA_ARGS: '--exclude=*.txt'
```

which excludes all files with .txt extension from deploy. If you want to exclude multiple, specific files, I believe you can replace the EXTRA_ARGS line with:

```
EXTRA_ARGS: '--exclude=file1.txt --exclude=file2.php'
```

If these files are not at the root of the repo, but inside a directory of the repo, make sure to specify the relative path to the file, instead of only its name.

Is this something that works for you?

Kind regards,  
Theodora


Tags: bitbucket-cloud

cloud