Creating new repository in Bitbucket and setup in local machine.

About Bitbucket

Bitbucket is a Git-based source code repository hosting service owned by Atlassian. Bitbucket offers both commercial plans and free accounts with an unlimited number of private repositories.

Today we are going to learn about create new repository in Bitbucket and setup that repository in your local machine.

Let’s start to creating new repository in Bitbucket.

Login to your Bitbucket account or create new account in Bitbucket.

Login to your bitbucket account using your bitbucket login access(email/password). If you don’t’ have an account, then you can create an account in bitbucket with a few simple steps. 

After logging into your bitbucket account the bitbucket redirects to your workspace overview page. It shows recent activity in your workspace.

Creating a new Repository

Click on Repositories menu in header after login. When you click on the Repositories menu it’s redirected to your repositories list page, in that page have Create Repository button. 

Click on the Create Repository button for new project repository. In that form have few fields. 

Enter the project name or select project if you already created it.

Then enter the repository name. I suggest setting the same name for your project. If your project name is Abcshop then just type abcshop in repository name field.

Those two fields are required other field is optional like Access level, include a README, Default branch name, Include .gitignore file. etc

If you checked Private repository(Access level) then it’s create private repository when you click create repository button, Else it creates the public repository.

Include a README?: If you select yes then it’s auto created README file and added to your repository.

Default branch name is main if you want to change then you can type your custom branch name.

Include .gitignore?: If you select yes then it’s auto created .gitignore file and added to your repository.

Click on Create repository button to create repository. It’s create README and .gitignore file if you have select yes in that two fields else it’s create blank repository.

That’s all for creating repository in bitbucket now we are going to setup that repository in your local machine.

Setup repository in your local machine

My local system is ubuntu 22.04 LTS, I already install git in my local machine. If your system does not have git then install git first.

Install git in ubuntu

Just type this commands in your terminal

sudo apt update
sudo apt install git -y

Install git in window

Download & install Git for Windows software in your local window machine.

Create repository access token for accessing and commit new files to your repository.

Login to your bitbucket account. Click on setting icon in top right corner.

Click on Personal Bitbucket settings. It’s redirect to personal setting. In left sidebar have App passwords link. It’s open the App passwords page.

Click on Create app password button.

For new token you need to provide token name and token permissions like read, write and delete or admin.

We must select Repositories Read, Write permission for read and write repository from local. I recommend to you give full permission if you accessing your personal repository. After that click on Create button.

Copy that text show in your popup box. It’s not visible again. Please keep save that in your notepad. we need this token when we need to pull, clone and push data in the repository.

Get bitbucket clone URL

Login to your bitbucket account and go to your repository. it’s look like below image.

Click on Clone button that is in top right corner.

When you click on Clone button it’s open this above popup. In this popup have dropdown in top right corner. Just select HTTPS in this dropdown. After that copy the full clone URL that is in text box(It’s showing like git clone https://xxxxxx@bitbucket.org/xxxxx/yourproject.git).

Using that command we are able to clone project repository in you local machine.

Setup repository in Ubuntu

Keep your copy git clone url in notepad or any editor.

Setup your bitbucket repository

Open terminal and go to your location where you want to setup this repository.

In my case I want to setup in /var/www/abcshop. So I am move to this location using cd /var/www/abcshop

After that you just need to paste the git clone URL and enter.

After press enter asking password, you need to copy your access token and paste here and please press enter key.

it’s shows like this.

After that you just need to enter more command that is move git data to you current directory. If you current directory is have data or your current directory don’t have data that is work on both case. So, you can setup this in both project new and existing project or you can manually cut and paste to the current directory(git clone create project name directory to your current location you just need to cut all files from that folder and paste to your current directory).

mv abcshop/* abcshop/.* ./

Now you can run all the git command in your project like git add, git commit and git push.

Your git repository is setup in your ubuntu machine. Now you are able to pull, add, commit and push your changes to your repository.

Setup repository in Windows

Please keep git clone URL and access token in your notepad.

If you need to create new project then create project folder.

Open Git Bash and move to your project folder. in my case I have create project in D:/abcshop

After that just paste the git clone URL and press enter.

After that it’s asking password. Just copy access token and paste in the password field.

After enter your password and click Sign In button and then your repository is download in your current folder.

Now you need to move your git repository to your current folder. Please type this command to move all the git data to your current folder.

mv abcshop/* abcshop/.* ./

Now you can run all the git command in your project like git add, git commit and git push.

Your git repository is setup in your windows machine. Now you are able to pull, add, commit and push your changes to your repository.

Fill free to ask me any of the Magento issues or contact me if your need any customisation or other Magento related service.

Will provide you these Magento services click here for more details

Leave your comment

Your email address will not be published. Required fields are marked *