Locked lesson.
About this lesson
Quick reference
BitBucket For Version Control
BitBucket.org allows us to save our version controlled code on a third party website for safe keeping.
When to use
Normally I suggest Github.com, but if you want to keep your code private Bitbucket.org offers free private repositories. Github.com makes you pay for private repositories.
Instructions
Sign up for a free account at BitBucket.org
Next, copy your C9 ssh key by issuing this command in the terminal:
- cat ~/.ssh/id_rsa.pub
Copy and paste the whole block of text from the terminal, then log into your BitBucket.org account and click the "BitBucket settings" icon in the top right corner of the screen. Next, click the "SSH Keys" link on the left side of the screen.
Click the "Add Key" button at the top of the screen. Type in a name you like in the "Label" field, then paste your SSH key into the "Key" field. Click the "Add Key" button to save.
Next we need to create a new repository and link it to our C9 account. Click the "Repositories" link at the top of the screen, and then "Create Repository".
Name it anything you like, I suggest Pinteresting. Then click the "Create Repository" button.
Next scroll down to the bottom of the page and click the "I have an existing project" link. This will give us the two commands we'll need to connect our BitBucket repository to our C9 account.
Copy and paste the two commands listed into your C9 terminal:
- git remote add origin ssh://git@bitbucket.org/username/reponame.git
- git push -u origin master
Finally, to push your code to bitbucket from now on, issue these three commands from the C9 terminal:
- git add .
- git commit -am "Commit Message"
- git push
Hints & tips
- Bitbucket.org offers free private code repositories
- Once you connect to BitBucket.org once, you can push code from then on with the "git push" command
- You don't need to log into BitBucket.org every time you write code
- 00:05 In the last video I talked about GitHub.
- 00:06 In this video I wanna talk about Bitbucket.
- 00:08 Now Bitbucket acts very much like GitHub does, it does the same exact thing,
- 00:12 their websites look a little bit different but basically they do the same thing.
- 00:16 The reason why, like I said in the last video that you would choose Bitbucket over
- 00:21 GitHub is because Bitbucket will give you private repositories.
- 00:25 Whereas GitHub gives you just free public repositories, right.
- 00:30 So if you wanna keep your stuff private at GitHub you have to pay but Bitbucket will
- 00:34 give you one free repository that's private so you don't have to pay.
- 00:37 So I mean, I would choose GitHub over Bitbucket all the time.
- 00:41 I don't ever use Bitbucket for anything really, but
- 00:43 if you wanna keep yourself private, Bitbucket's the way to go.
- 00:46 And we set it up the same exact way with GitHub.
- 00:50 Go to Bitbucket.org, that's the website, if you don't have an account, sign up,
- 00:53 it's totally free.
- 00:54 And like in the last video we need to add our SSH keys to authenticate.
- 01:00 So if you go to Bitbucket settings and then look down here,
- 01:04 it even looks similar.
- 01:05 You click this SSH keys, click add key, Pinteresting, we do the same thing.
- 01:12 We issue that cat and then the tild
- 01:17 sign /.ssh/id_rsa.pub,
- 01:22 and that gives us our SSH key.
- 01:26 We can highlight this, click Copy,
- 01:30 come back over here, paste that in.
- 01:35 Click Add Key, and then boom, there it is, right.
- 01:40 Come back here, now we need to create a new repository.
- 01:43 So click on Repositories up here, Repositories.
- 01:47 And then Create Repository.
- 01:49 And let's call this Pinteresting.
- 01:52 And you can choose Git or Mercurial, we want Git.
- 01:56 This is a private repository.
- 01:59 And then click Create Repository.
- 02:02 Now just like before with GitHub, we need to connect our account.
- 02:09 Basically the same two commands that we copied and pasted at GitHub,
- 02:13 we're going to copy and paste here at Bitbucket.
- 02:16 So highlight that, click Ctrl+C or command-C or right-click and hit Copy.
- 02:22 Come back here and actually I'm gonna clear that screen, you can paste that in.
- 02:27 I'm not gonna click, I'm not gonna do this 'cause we've already connected with Github
- 02:30 and you don't wanna connect to both of them.
- 02:32 It's gonna throw things off but
- 02:34 if you choose to use Bitbucket you just copy that in, click Enter.
- 02:38 Come back here and do the same thing, copy this, come back,
- 02:42 paste, click Enter, and you're good to go.
- 02:45 And just like at GitHub, whenever we wanna push up our code we do the same thing.
- 02:49 We do git add ., then we do git commit am,
- 02:54 give it a description.
- 03:00 You notice I'm not actually entering these commands,
- 03:02 'cause we've already done it for GitHub.
- 03:03 And then to push your code to BitBucket, just like to push your code for
- 03:08 GitHub, just type get push.
- 03:10 And that's it, very similar to GitHub, they do the same thing.
- 03:14 The only difference is BitBucket allows you to have private repositories.
- 03:19 If you're trying to get a job you want your potential employers to be able to
- 03:23 look through your GitHub account and
- 03:25 see your code to prove to them that you know what you're doing.
- 03:28 You can't do that if you have a Bitbucket account, right.
- 03:31 On the other hand if you're not trying to find a job, and
- 03:33 you're trying to build your own start-up well,
- 03:35 then maybe you don't want other people to see your code, right.
- 03:38 If you're building a company or
- 03:39 something you don't want other people to see you code.
- 03:41 So you might wanna use Bitbucket.
- 03:43 So they're both free, both very easy to use and
- 03:45 we actually probably won't ever come back to GitHub or to Bitbucket.
- 03:50 Once you set it up here, we'll push our code but
- 03:52 we very rarely actually go look at it.
- 03:54 It's only for catastrophe, if you need to download your code to another machine or
- 03:58 something you can download it from GitHub in the future.
- 04:01 So that's GitHub, that's Bitbucket, that's version control, and
- 04:05 we are one step away from starting our project.
- 04:08 Now we just need to talk very quickly in the next video about web hosting our
- 04:12 production level quality website with Heruko.
- 04:15 And then we can actually start writing code and building something cool and
- 04:19 that's when the fun stuff starts.
Lesson notes are only available for subscribers.