Working with bitbucket: create RSA keys, init repository, commit and checkout

Working with bitbucket: create RSA keys, init repository, commit and checkout

Posted: 10 years ago in  Unix | Miscellaneous |


Bitbucket has same features as Github, Launchpad. They provide revesion management for website/application developements.


Bitbucket has same features as Github, Launchpad. They provide revesion management for website/application developements.

The difference is client they use. Github use SVN (subversion), Launchpad prefer BZR (Bazaar) and Bitbucket play with Git and Mecurial.

All steps from this guide is also available on bitbucket documentation. I just sum up and make a list of common command.

Create RSA key on local machine and import the public key to bitbucket account

Tips: to know if any RSA key existed, looking for file ~/.ssh/id_rsa.pub

Open Terminal

ssh-keygen

Keep enter for create pair of key (public and private)

View public key by using cat

cat ~/.ssh/id_rsa.pub

Key will be like

ssh-rsa AAAQuKY3.......DzbP0d/xkACCc+zufD username@laptopname

Copy all text and paste to Bitbucket account => Manage Account => SSH Keys (found in Security tab)

Create Private Repository on Bitbucket

Login to account and click Create on the Menu top

Input information as project name, mark as private, permissions to fork, etc...

Init repository on local pc and commit to previous created repository

projectname is from previous step

There are 2 scenarios where you have nothing on local pc and you are developing new project. Steps is bit different.

For Starting with Blank Sourcecode:

Create project folder on local

Go into folder, then

git init
git remote add origin git@bitbucket.org:bitbucketusername/projectname.git

Create first file to commit to repository

echo "Luan Tran" >> contributors.txt
git add contributors.txt
git commit -m 'Initial commit with contributors'
git push -u origin master

For Starting with Existing Sourcecode:

Go into folder, then

git remote add origin git@bitbucket.org:bitbucketusername/projectname.git
git push -u origin --all
git push -u origin --tags

During developement, there are some common commandline to work with:

git status: display changes

git add: add file for commitment

git commit: commit a revision

git push: push all pending commitments to repository

Hope you are getting familiar quickly with git and bitbucket