New to Bitbucket Cloud? Check out our get started guides for new users.
Add unversioned code to a repository
If you have code that is currently not under version control and you want to start controlling it, you can prepare it by putting your code into a Git repository locally. From there, you push it to Bitbucket.
If you don't yet have a Bitbucket repository, create a repository first.
Add to a Git repository
From your terminal, change to the root directory of your existing code.
Initialize the directory under version control from the following command:
$ git init
Add the existing files to the repository you have initialized:
$ git add .
Commit the files:
$ git commit -m "initial commit of full repository"
On macOS, you can use either single quotes or double quotes around the comment message. On Windows, you must use double quotes.
Connect your new local Git repository to the remote repository on Bitbucket. To do so, enter git remote add origin with the remote URL:
$ git remote add origin <bitbucket_URL>
You can find the URL next to the git clone command for the repository.
Push all the code in your local repo to Bitbucket with the following command:
$ git push -u origin --all
Was this helpful?