Accessing repository

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

This widget could not be displayed.

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?

This widget could not be displayed.
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).
This widget could not be displayed.

Very good. Thanks for the information.

This widget could not be displayed.

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

@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.

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)

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?

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.

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

Thanks so much for your help.

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.

Good tip

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 21, 2018 in Bitbucket

Branch Management with Bitbucket

As a project manager, I have discovered that different developers want to bring their previous branching method with them when they join the team. Some developers are used to performing individual wo...

1,266 views 8 11
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you