Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Sharing a same Git repository on 2 computers

Benjamin Melki May 4, 2014

Hi,

first thanks for the great service you are providing.

i'm using webstorm on ComputerA and B.

On computerA, I correctly set webstorm to use GIT repository on Bitbucket, and i'm able to push my commits there.

Now, on computerB, where I also have webstorm installed, I would like to retrieve the same repository from Bitbucket -> ComputerB. Also I would like to be able to make change from computer A or B, and have it synch on both computers, from Bitbucket repository.


How should I do to get files copied from the repository into computerB? Should I create several users on Bitbucket ? Because I try to access bitbucket on computerB with same user.

So I tried to setup access to same repository on computerB, then "fetched" project: that was successfull but no file were downloaded. So what should I do ?

5 answers

1 accepted

1 vote
Answer accepted
Deleted user May 5, 2014

It's not a problem to use the same Bitbucket account to clone a repository to a multiple computers and work independently on the computers and sync the changes via Bitbucket repository. I have several cases where I do exactly that - it's just a normal git workflow.

Think it this way: from git point of view the following cases are equal:

  • user A has three clones of a repository in three different computers
  • users A B and C each have a single clone of a repository in their own computers

In both cases commits can be made to all the local repositories and pushed to and pulled from Bitbucket.

Seth
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 5, 2014

I agree that this is the best way. But the OP's own answer says (paraphrased): I cloned to both machines and tried pulling to each. It works, but I don't know if it is a viable solution.

I'm not sure why he says that it might not be viable, but if he doesn't want to have to pull, things are going to get complicated.

0 votes
Jatin June 20, 2020

I am implementing a similar workflow. Did it work in the long run as expected?

I found this link here which suggests that having different SSH keys for both the machines is best practice. 

0 votes
Benjamin Melki May 5, 2014

Hi thanks for your answers, I confirm I got that working.
From computerA I initally pushed my app code into bitbucket.
Then on computerB, from webstorm I chose to clone from VCS first thing, then choose, Git, then specified my bitbucket URL. This cloned the content online into computerB.


Now, whenever I make a change on one computer, I comit and push, and on the other computer I go into the concerned branch and update project. And I got all the changes, so it works as intended.

It's not a problem that I have to comit / push / update, sorry if I was not clear Seth.

Seth
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 5, 2014

No problem. You are doing it the right way.

0 votes
Benjamin Melki May 4, 2014

I tried to clone git directory on both machines, then pull the changes to update code on both... seems to work, but not sure if its a viable way

0 votes
Timothy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 4, 2014

What you're asking is not possible using Git. What you should do if you want to work like that is to put the code in a shared folder that both PC's will use.

Seth
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 4, 2014

If the project is small enough, use a tool like DropBox that keeps files in sync AND local (Git sometimes has odd problems operating on network shares). As long as the entire repository is in DropBox (including .git/) you should get the result you're looking for.

Note: Do NOT attempt to modify the repository on both computers at the same time using this method.

Deleted user May 5, 2014

Err ... I fail to see why this can't be accomplished. Every git repository clone is a first-class citizen and can work with numerous remote repositories. I have several cases where I have cloned a repository from Bitbucket to multiple computers using the same account and I keep them sync via Bitbucket - that's just a normal git workflow.

Seth
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 5, 2014

I interpret Benjamin's question (especially after reading his second answer) as wanting his repositories to stay in sync without the extra step of pulling.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events