How many clones of repository are required?
Asked by Sneha Bhasin:

We are using sourctree on RDS to connect to bitbucket.

Is it necessary to clone repository for each user or a single clone can be shared by all users?

Cloning repository/user will occupy lot of space. Can someone suggest any alternative wherein all users can access a single clone from the bitbucket?


Answers:
author: Ben Stuart
body: Hey Sneha, I'm not sure I understand you question. Usually each user will have a local clone of the central repository. Each user will push their changes/ branches to the central repository. Or are you talking about personal [forked repositories](http://www.atlassian.com/git/tutorials/comparing-workflows/forking-workflow)?

I would suggest you read [Comparing Workflows](https://www.atlassian.com/git/tutorials/comparing-workflows) for a detailed explanation and examples.

comments: author: Sneha Bhasin
body: [@Ben Stuart](/t5/user/viewprofilepage/user-id/747353)

Hi Ben. My question is that is it possible that we maintain one common clone which is accessed by each user and each user pushes his/her change to this clone which inturn pushes to the target location.?

We are using Tortoise Git as a client for Bitbucket and once we commit changes, Jenkins will trigger build. Our Tortoise GIT is on RDS.

Do you think with these tools , such a setup is possible?


author: Ben Stuart
body: Hey Sneha,

I don't think this setup would be feasible or efficient for how Git was designed to be used. This sounds pretty similar to a forking model though. Check out [forked repositories](http://www.atlassian.com/git/tutorials/comparing-workflows/forking-workflow?_ga=2.216211094.1095543882.1518423677-1239588266.1518423677). You can have all your developers working on the fork and then create pull requests to the primary repository once you finish with your changes. I could be misunderstanding your use case though. Maybe you can explain more why you would like this workflow and what you're trying achieve by setting it up in this way.


author: Sneha Bhasin
body: [@Ben Stuart](/t5/user/viewprofilepage/user-id/747353): Could you suggest any git clents for bitbucket that could help me achieve this(single clone for all users)?

The issue is that if each user maintains a clone of repository, that is occupying a lot of space and that is what we are trying to overcome


author: Ben Stuart
body: I'm not sure of any Git clients that could do this as it goes against the nature of [Distributed Version Control System](https://en.wikipedia.org/wiki/Distributed_version_control)s. If you're mostly concerned with disk space on your developer's local machines, I have a few suggestions that may help.

If your repository is very large due to file sizes or number of branches, your developers can use the following command to clone a branch or subsection of the repository.

    git clone <url> --branch <branch> --single-branch [<folder>]

If your repository is large due to a long commit history, your developers may just want to clone one or two commits with a "Shallow Clone" command like this:

```
git clone --depth [depth] [remote-url]
```

I would recommend you read[How to Handle Big Repositories with Git](https://www.atlassian.com/blog/git/handle-big-repositories-git) for more information.

There are also ways you [can reduce the size of your repository](https://confluence.atlassian.com/bitbucket/reduce-repository-size-321848262.html) which might be helpful. You can ignore the Bitbucket Cloud related restrictions described there and focus on these sections:

* [Understand file removal in a Git repository](https://confluence.atlassian.com/bitbucket/reduce-repository-size-321848262.html#Reducerepositorysize-UnderstandfileremovalinaGitrepository)
* [How Git history rewrite works](https://confluence.atlassian.com/bitbucket/reduce-repository-size-321848262.html#Reducerepositorysize-HowGithistoryrewriteworks)
* [Using the BFG to rewrite history](https://confluence.atlassian.com/bitbucket/reduce-repository-size-321848262.html#Reducerepositorysize-UsingtheBFGtorewritehistory)
* [Alternatively, using git filter-branch to rewrite history](https://confluence.atlassian.com/bitbucket/reduce-repository-size-321848262.html#Reducerepositorysize-Alternatively,usinggitfilter-branchtorewritehistory)
* [Manually reviewing large files in your repository](https://confluence.atlassian.com/bitbucket/reduce-repository-size-321848262.html#Reducerepositorysize-Manuallyreviewinglargefilesinyourrepository)
* [Running filter-branch](https://confluence.atlassian.com/bitbucket/reduce-repository-size-321848262.html#Reducerepositorysize-Runningfilter-branch)
* [Delete files by name](https://confluence.atlassian.com/bitbucket/reduce-repository-size-321848262.html#Reducerepositorysize-Deletefilesbyname)
* [Delete just the branch](https://confluence.atlassian.com/bitbucket/reduce-repository-size-321848262.html#Reducerepositorysize-Deletejustthebranch)
* [Garbage collecting dead data](https://confluence.atlassian.com/bitbucket/reduce-repository-size-321848262.html#Reducerepositorysize-Garbagecollectingdeaddata)
* [How to reduce a Mercurial repository](https://confluence.atlassian.com/bitbucket/reduce-repository-size-321848262.html#Reducerepositorysize-HowtoreduceaMercurialrepository)
* [How to find large files](https://confluence.atlassian.com/bitbucket/reduce-repository-size-321848262.html#Reducerepositorysize-Howtofindlargefiles)
* [Removing large files](https://confluence.atlassian.com/bitbucket/reduce-repository-size-321848262.html#Reducerepositorysize-Removinglargefiles)
* [Example of using convert to reduce repository files](https://confluence.atlassian.com/bitbucket/reduce-repository-size-321848262.html#Reducerepositorysize-Exampleofusingconverttoreducerepositoryfiles)

I hope that helps!


author: Sneha Bhasin
body: [@Ben Stuart](/t5/user/viewprofilepage/user-id/747353)Thanks a lot Ben


Tags: bitbucket