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

Accessing repository

Ed June 29, 2016

I'm really new to git and Bitbucket. I want to use it for my shell scripts. I have already created a repository from my work laptop to push all my shell scripts to the repository at Bitbucket. Now, I would like to setup my scripts folder on my home computer to sync the scripts, from my laptop and my desktop, into one repository.

How do I connect to the Bitbucket repository from my home computer that I setup from my work laptop using the same account? Is there documentation somewhere on how to do this?

Thanks.

5 answers

2 votes
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.
June 29, 2016
0 votes
Tim Crall
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.
June 29, 2016

If you have scripts on your home computer that are different than the ones on the work computer (and thus in the remote repo) that you want to keep, you should copy them into the clone folder and add them to the repo with git add / git commit / git push

Ed June 29, 2016

@tim crall

Thanks.

Yeah, I was able to work it out. I created a clone and was able to get everything sorted the way I wanted. I guess the only thing I need to remember to do from this point forward is that every time I change a script that I need to copy it to the cloned repo folder on that specific computer.

Tim Crall
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.
June 29, 2016

That doesn't sound quite right.  Moving forward, I'd edit the scripts directly in the repo (and set your path or whatever to use the scripts out of the repo)

Ed June 29, 2016

Ok. So I must have done something wrong.

Initially, I had a repo on Bitbucket named 'scripts'. I had setup my work laptop as the local repo before setting up a clone. On my work laptop the name of the repo directory is also called 'scripts'. To start over I deleted the repo on Bitbucket and remove the .git directory from with my 'scripts' folder on my laptop. I then created a new, empty repo on Bitbucket named 'scripts_repo'. I then went my laptop and, from within the 'scripts' directory, ran the git clone command. Once that happened it created a new directory within the 'scripts' directory called 'scripts_repo'. Then I just copied my scripts to the 'scripts_repo' directory and pushed it.

So, I did something wrong?

Tim Crall
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.
June 29, 2016

I wouldn't think that, moving forward, you would want to keep a separate "scripts" folder and "scripts_repo" with all the same content.

You should just be able to have your "scripts" folder itself be a repository.

I think the way you had it on your work laptop and Bitbucket originally was fine, from what I can tell.  At this point I would copy 'scripts_repo' to the location where you want your scripts folder to be, make absolutely sure that everything from 'scripts' is identical inside 'scripts_repo', and then delete 'scripts' and rename 'scripts_repo' to 'scripts'.

Then I would clone the remote repo onto your home computer.  If there are scripts on your home computer that aren't  in the repo yet, I'd copy them into the repo and add/commit/push.  Then I'd delete the scripts folder on your home computer and move the cloned repo to the same location.

Ultimately you should have a 'scripts' folder on each computer which is a clone of the 'scripts' repo on the server.  There's no need to have a repo separate from the folder itself, unless I'm missing something that you're trying to accomplish.

Ed June 29, 2016

Got it. All is working the way I want now.

Thanks so much for your help.

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.
June 30, 2016

Also, keep in mind that git doesn't care what the name of the folder is that contains your repo. By default it will match the name of the remote repo, but that isn't required. The important thing is the .git folder; all of the folders and files starting at its level are considered to be part of the repo.

So, you can clone your repo, then rename the parent folder (currently scripts_repo) to anything you want, and/or move it anywhere you want.

Ed June 30, 2016

Good tip

0 votes
Ed June 29, 2016

Very good. Thanks for the information.

0 votes
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.
June 29, 2016
Yes, cloning is absolutely the best practice - this is how Git is designed (De-Centralized Versioning System). Each location where you have the code is a fully-functioning repository. When you clone, the server you clone from becomes a "remote", which is available to push to and pull from. By cloning the Bitbucket repository to two locations, you commit and push on your laptop, then pull on your desktop, or vice versa. If one location is going to be read-only, it would be pretty safe to try to set up some sort of auto-pull (google it).
0 votes
Ed June 29, 2016

I want to clone? Why would I clone if I want to access the same repository and sync the scripts between the two computers? Is this best practice, to clone?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events