Loading
Loading
  • Home

  • Productivity

  • App tutorials

App tutorials

2 min read

How to Push to Bitbucket

By Khamosh Pathak · June 10, 2019
how-to-push-to-bitbucket primary img

Bitbucket allows you to reliably track all changes and updates to your code base, merge requests from different teams, and easily roll back changes while making your repository available to your entire team.

Here's how to push to Bitbucket.

How to Create a New Repo in Bitbucket

Before you can push to a repository, you'll first create a new one.

Log in to Bitbucket, and then click the menu button in the top left. From the sidebar, click on the plus button, and select Repository.

Create new repository

Give the repository a name, and make sure the Version control system is Git. For the Include a README? option, switch to No.

Click Create repository to make a new repository.

How to Push to Bitbucket

Once a new repository is created, you'll be taken to a blank page with instructions to populate the repository. From this page, note the URL of your repository. It will be on the top text box (make sure to ignore the git clone text when copying the link).

Copy URL of repository

Now, you'll use the command line to upload files and push new changes to the repository. If you're using a Mac or Linux machine, open the Terminal. If you're on Windows, use Git Bash.

After opening the terminal, use the cd command to navigate to the folder that you want to sync using the repository. Then, to start the Git process, use the following command:

git init

git init

Now, you'll sync the online repository with your local folder. In the following step, paste the link to the Bitbucket repository at the end of the command (make sure it ends with a .git suffix).

git remote add origin <repo link>

alt

Next, stage the files for the syncing process by adding them to Git with the following command.

git add .

Then, to make sure that all files are added, check the Git status.

git status

git status

Before you start the remote sync process, you'll make the first commit. A commit is similar to adding a comment: When you look back at the code changes later, you can quickly recall what this particular update was about. Use the following command:

git commit -m "first commit"

first commit

Now it's time to finally push the folder contents to the remote repository at Bitbucket. Type the following command, and press Enter or Return.

git push origin master

git push origin master

If you're doing this for the first time, you'll be asked to enter the password associated with the Bitbucket account that's linked to the repository. This is just a security measure to make sure that only the owner of the private repository can make changes to it.

Once the authentication is done, you'll see updates about the upload process. In a minute or two, the process will be done and you'll see a message saying so.

To check if the push process worked, you can open the Bitbucket repository in your browser. Instead of the empty page, you'll now see all your files and folders in the list.

Confirmation message

If you want to track commits and see all changes, click on the menu button and select Commits.

Want to learn more about Bitbucket? Check out our Bitbucket overview for tutorials and ways to integrate Bitbucket with thousands of apps.

Get productivity tips delivered straight to your inbox

We’ll email you 1-3 times per week—and never share your information.

tags
mentioned apps

Related articles

Improve your productivity automatically. Use Zapier to get your apps working together.

Sign up
A Zap with the trigger 'When I get a new lead from Facebook,' and the action 'Notify my team in Slack'