Easy way to keep a copy of my repo on a USB?
Asked by Juan:

Is there any easy way to keep a copy of my repo on a USB by using Sourcetree + Mercurial + Bitbucket?

I mean having a everything synchronized with my local working directory and my remote repository at Bitbucket or Github?

Here some people explains how to do it with git commands

<https://stackoverflow.com/questions/38153478/copying-a-git-repository-to-usb-drive>

But I'd like to get it from the Sourcetree GUI, and I'm using Mercurial at Bitbucket, though a Git solution would also be nice..

I'm using repository to keep a copy of a project I'm doing for my PhD. And I work both from the university and home. But sometimes I don't have Internet at home and I need to rely on a USB.


Answers:
author: Juan
body: Then I will end up having two repos, one on my pendrive and another one on my hard disk and every day I will need to push the content of any of them to bitbucket and later pull it back to the other repo (for example disk -\> bitbucket -\> usb), isn't it?


author: Juan
body: Maybe I can do it by cloning the repository to my USB.

<https://confluence.atlassian.com/bitbucket/clone-a-repository-223217891.html>

But I can't find the "Clone" option on Sourcetree.

Where is it?

![](https://i.imgur.com/EH6lGIc.png)

comments: author: Ana Retamal
body: Hola Juan!

If you have your repo locally in your machine, you don't need to clone it (a clone would be a copy from the remote repository if it was hosted in Bitbucket for example), you can import it into Sourcetree using the menu on top: **File \> New \> Add existing local repository** and navigate to the directory where your repo is.

Could you do it?

Saludos,

Ana


author: Juan
body: I named Git just as an example and possible alternative but I'm really interested on a Mercurial solution.

The truth is that I know very little about all these tools. I've decided to use Mercurial through SourceTree because it's more comfortable than the command line.

And yes, manually copying the folder every day is what I was trying to avoid. I'd like to keep everything synched on Bitbucket and my USB by just pressing the "Pull" option on SourceTree.

Muchas gracias Ana.


author: Ana Retamal
body: Hi Juan, welcome to the Community!

First of all, let me say this is not a question about Bitbucket or Sourcetree, more about Mercurial, but let me try to help anyway.

If you're already using Bitbucket, Github, and Sourcetree and have copies of your repo in all the three of them, you'll be able to always have them in sync. Getting a copy of your repository in your USB drive is as simple as copy-pasting the whole directory into it.

The article you linked is doing something different because it's not just keeping a copy of the repo, is adding it as a remote, which I believe would work better in your case. If you'd like to do that, you'll need to use Mercurial commands (not Git) and I recommend you check their documentation at <https://www.mercurial-scm.org/wiki/QuickStart>. You won't be able to do that from Sourcetree, you'll need to use the terminal, though. Is there any reason why you'd want to use Sourcetree for that?

Is there a reason why you'd want to use Git too? Mercurial and Git are different systems, and you'd need to convert from one to the other, or you could use [this plugin](http://hg-git.github.io/) to collaborate to the same repo using both systems.

Hope that clarifies some things, Juan. Let us know if you have any questions!

Cheers,

Ana


Tags: git

mercurial