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

  1. From your terminal, change to the root directory of your existing code.

  2. Initialize the directory under version control from the following command:

    $ git init

  3. Add the existing files to the repository you have initialized:

    $ git add .

  4. 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.

  5. 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.

  6. Push all the code in your local repo to Bitbucket with the following command:

    $ git push -u origin --all

Additional Help

Ask the Community