Author Topic: SourceTree repository duplicate/clone on second local drive  (Read 2311 times)

0 Members and 1 Guest are viewing this topic.

Offline ricko_ukTopic starter

  • Super Contributor
  • ***
  • Posts: 1015
  • Country: gb
SourceTree repository duplicate/clone on second local drive
« on: November 06, 2021, 06:21:45 pm »
Hi,
not very familiar with SourceTree (I just use the bare essential features).

I have some projects on C: and the SourceTree (Git) local repositories are within their folders (I use only local repositories, not online) but want to have a second copy on D: drive, The second copy on D: would preferably be automatically updated when I commit to the first repository on C: or alternatively I can commit manually, either would be acceptable.

So is it possible? If so, how?

I tried clone but didn't work.

Thank you :)
 

Offline newbrain

  • Super Contributor
  • ***
  • Posts: 1721
  • Country: se
Re: SourceTree repository duplicate/clone on second local drive
« Reply #1 on: November 07, 2021, 12:08:43 am »
I tried clone but didn't work.
I'm not familiar at all with Sourcetree, but what did not work cloning locally?
Code: [Select]
~\Git\AD9834 [master ≡]> git clone . ..\ADclone
Cloning into '..\ADclone'...
done.
~\Git\AD9834 [master ≡]> Get-ChildItem ..\ADclone\

    Directory: C:\Users\newbrain\Git\ADclone

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----          2021-11-07    00:50                Inc
d----          2021-11-07    00:50                Src
[...]
~\Git\AD9834 [master ≡]> cd ..\ADclone\
~\Git\ADclone [master ≡]> git remote -v
origin  C:/Users/newbrain/Git/AD9834/. (fetch)
origin  C:/Users/newbrainGit/AD9834/. (push)
~\Git\ADclone [master ≡]>
Of course the target directory can be on any reachable path.

As you can see, the newly created clone already has its remote set to the the cloned repository.
If you commit there, just do "git push origin" to update the original directory.

If you prefer, instead, to work on the original directory and then update the clone, you need to remove (optional, but advised to avoid mixups) the remotes from the clone:
Code: [Select]
~\Git\ADclone [master ≡]> git remote rm origin
~\Git\ADclone [master]> git remote -v
~\Git\ADclone [master]>
And set them in the original repo, "origin" is the default choice, but any name will work:
Code: [Select]
~\Git\AD9834 [master ≡]> git remote add origin ..\ADclone
~\Git\AD9834 [master ≡]> git remote -v
origin  ..\ADclone (fetch)
origin  ..\ADclone (push)
~\Git\AD9834 [master ≡]> git push origin
Everything up-to-date
~\Git\AD9834 [master ≡]>
Nandemo wa shiranai wa yo, shitteru koto dake.
 

Offline ricko_ukTopic starter

  • Super Contributor
  • ***
  • Posts: 1015
  • Country: gb
Re: SourceTree repository duplicate/clone on second local drive
« Reply #2 on: November 07, 2021, 01:45:56 am »
Thank you newbrain :)

Not familiar with Git at all, even less with its command line. Where do I access it? I installed only SourceTree and cannot see any Git folders on my hard drive. Any idea where it is?

Thank you
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9964
  • Country: nz
Re: SourceTree repository duplicate/clone on second local drive
« Reply #3 on: November 07, 2021, 02:28:13 am »
I'm pretty sure everything you need is contained in the repo folder.  (The .git folder under there contains all your history/changes)

So you should be able to simply copy the entire repo folder to D: drive in window explorer.
I can't remember if there any any hidden files as part of a repo folder, but you might want to check that or enable "show hidden and system files" in windows explorer just to be safe.

Once you have a copy of the repo folder on D: you should be able to add that one too sourcetree as a new repo, if you want.
(file open, select the folder). It should find all the history inside the .git folder and just make a new TAB in source tree. Though you might want to rename the folder so you can tell them apart.

However without an online copy to push and then pull from it's hard to sync the two copies.
I guess you could simply schedule an automatically xcopy/rsync in windows to copy the folder to D: every time you start up the PC.
An online git copy is easier and would give you a backup which is I'm guessing why you are trying to make a D: copy.
Setting up free Atlassian git account is pretty easy, if putting your source online makes you feel uncomfortable a lot of big companies use it for storing their source.  Just make sure you setup the Atlassian repo as a 'PRIVATE' one :D

« Last Edit: November 07, 2021, 02:35:04 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline ricko_ukTopic starter

  • Super Contributor
  • ***
  • Posts: 1015
  • Country: gb
Re: SourceTree repository duplicate/clone on second local drive
« Reply #4 on: November 07, 2021, 02:34:48 am »
Thank you Psi! :)

I did try setting one up on GitHub a while back but for some reason I could not get it to work. I posted few times on SourceTree for help but no replies. So I gave up.

Is it easier to create an Atalassian repository? From your post it sounds like they provide the same as GitHub? Is that correct?

Thank you
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9964
  • Country: nz
Re: SourceTree repository duplicate/clone on second local drive
« Reply #5 on: November 07, 2021, 02:42:33 am »
I've only ever used Atlassian so i'm not sure if its easier or harder than github.

I'm not sure if you can upload you current repo onto Atlassian, I've never tried doing that. I always create a new repo and move my files into the new one. But this means your change history starts again. Of course you still have your old repo for that.

You simply create yourself an Atlassian account.
Then go and create a new 'PRIVATE' repo.
Once created there is a option in Atlassian for that repo to 'clone in sourcetree'
I think that will launch the sourcetree app, or maybe you have to copy/past the URL, cant remember.

Then you can copy your files into this new repo folder (only copy your files not git folder)
And finally push those changes to Remotes  / Origin / Master.

« Last Edit: November 07, 2021, 02:44:22 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline ricko_ukTopic starter

  • Super Contributor
  • ***
  • Posts: 1015
  • Country: gb
Re: SourceTree repository duplicate/clone on second local drive
« Reply #6 on: November 07, 2021, 02:51:37 am »
Thank you Psi! :)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf