How to create a Repository on Bitbucket and commit code using Git commands

Assuming that you have a project on your laptop and you would like to create a repository on Bitbucket website and commit your code, following are the steps.

  • Create a new repository on Bitbucket website
  • Click on “I have an existing project”
  • Open Command console on your laptop and navigate to the folder where your project code is
cd path/to/your/project
  • Run command
git init
  • Run command
git add --all
  • Copy and run the command that looks like the following
git remote add origin https://your-login@bitbucket.org/teamname/your-repo-name.git
  • Run command
git commit -m "my first commit"
  • Run command
git push -u origin master