SourceTree repository duplicate/clone on second local drive - Page 1
Forum section: electronics / general

author: ricko_uk
author_rank: Super Contributor
timestamp: November 06, 2021, 06:21:45 pm
content: 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

author: newbrain
author_rank: Super Contributor
timestamp: November 07, 2021, 12:08:43 am
content: Quote from: ricko_uk on November 06, 2021, 06:21:45 pmI'm not familiar at all with Sourcetree, but what did not work cloning locally?Code:~\Git\AD9834 [master ≡]> git clone . ..\ADcloneCloning into '..\ADclone'...done.~\Git\AD9834 [master ≡]> Get-ChildItem ..\ADclone\Directory: C:\Users\newbrain\Git\ADcloneMode LastWriteTime Length Name---- ------------- ------ ----d---- 2021-11-07 00:50 Incd---- 2021-11-07 00:50 Src[...]~\Git\AD9834 [master ≡]> cd ..\ADclone\~\Git\ADclone [master ≡]> git remote -vorigin 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:~\Git\ADclone [master ≡]> git remote rm origin~\Git\ADclone > git remote -v~\Git\ADclone >And set them in the original repo, "origin" is the default choice, but any name will work:Code:~\Git\AD9834 [master ≡]> git remote add origin ..\ADclone~\Git\AD9834 [master ≡]> git remote -vorigin ..\ADclone (fetch)origin ..\ADclone (push)~\Git\AD9834 [master ≡]> git push originEverything up-to-date~\Git\AD9834 [master ≡]>

author: ricko_uk
author_rank: Super Contributor
timestamp: November 07, 2021, 01:45:56 am
content: Thank you newbrainNot 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

author: Psi
author_rank: Super Contributor
timestamp: November 07, 2021, 02:28:13 am
content: 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

author: ricko_uk
author_rank: Super Contributor
timestamp: November 07, 2021, 02:34:48 am
content: 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

author: Psi
author_rank: Super Contributor
timestamp: November 07, 2021, 02:42:33 am
content: 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.

author: ricko_uk
author_rank: Super Contributor
timestamp: November 07, 2021, 02:51:37 am
content: Thank you Psi!