Getting Started With And Using BitBucket

February 12, 2020/0/0
Home / Blog / Developer / Getting Started With And Using BitBucket

Git is an industry standard for working on projects with others and managing versions of your code. Written by the God Emperor of all things open source and dev related  Linus Torvalds, it has become the best method of protecting code around. With todays growing digital space, it’s one all developers need to learn to use, and I am happy to help. Even if you are not working on a team and just looking for a place to safe-fully save your projects, you need to be using git. In this guide, I will help you get started creating a repo and adding your code to the repo.

Available Git Clouds

The first thing is first, if you are going to store your code using git, you need some place to put it. There are guides available to for using git on your own server, but there are places on the internet that are popular, secure, and specifically made for storing and managing your code whether its just for yourself or a team. The most well known is Github.

Github is great! I use it myself! But make sure you are aware of what you are putting there. Github is mostly a place for open source code. I tend to put code there that I don’t mind sharing with others or getting help on. They have the ability to create private repos (repositories, think of it as a folder for your code or a project), but it requires a cost. Public repos are free. For that reason, the git cloud service I use the most for code I don’t want out there is Bitbucket.

Simply put, Bitbucket allows you to create as many public and private repos free of charge. It only starts to cost if you have a team larger than 5 people. Its where I put all of my apps’ code for save keeping.

Creating a New Repo in Bitbucket

After you create a Bitbucket account, start by creating a new repo.

Settings are pretty standard. Just name the repo and mark it as private if you wish it to be. Make sure you keep Version control system Git.

Click Create repository.

Pushing your code to BitBucket

Once your repo is created, you will be given a url for the repo.

Once you have that url, you are ready to open terminal.

Navigate to your project.

cd /folder/with/your/project

Note: if you have finder open, you can simply type “cd ” (note the space) and click/drag the folder onto terminal it will fill in the folder name

Once inside your project folder, type

git init

This will add initialize git for your code. You will then need to add your Bitbucket repo url as a remote origin.

git remote add origin https://your-repos-url

Next add all files in the folder to the git project. Note: you may not want to add ALL files to your project. If this is the case, look into the .gitignore file.

git add .

Once done, you can make sure what files are part of the project by using

git status

Next you need to create a commit. Simply put, in version control systems, a commit adds the latest changes to [part of] the source code to the repository, making these changes part of the head revision of the repository. You do this by typing

git commit -m "first commit"

The “first commit” part is a string of character that describe the commit you are making. This can be anything you like.

Now we get to push the commit to the remote location. Do that by typing

git push -f origin master

Note: The -f  “forces” the push to master. This is okay for your first initial commit, but be careful with commits moving forward.

You will be asked for your password to Bitbucket. You can try your password, but if you used a different service like Google or Microsoft to create your Bitbucket account, you will need an app password. Make sure you keep track of that, because once it’s created, you won’t be able to retrieve it again.

And that’s it! Once the upload is complete, your files are backed up on Bitbucket. Bitbucket has a lot a great features and git is an incredibly powerful tool for project and code management.

Where To Go From Here

After making changes to your code, you may want to upload new commits. To commit any new or modified files in your project, type the following.

git commit -a -m "commit message."

Navigation

Add comment