Import local folder in bitbucket

12,220

To import the local folder to bitbucket repo, you can follow below steps.

Prerequisitions:

  1. Install Git in your local machine
  2. Check if the local folder already in a git repo

    In the directory of the folder you want to import to bitbucket repo, execute:

    git rev-parse --show-toplevel
    

    If it shows not a git reposiroty that means the local folder has not been managed in git repo. Else, if it shows a parent directory, that means the local folder has been managed in git repo

Steps to import:

  1. Create a local git repo if the local folder not in a local git repo

    As the prerequisition 2 shows, if the local folder has not been managed in a local git repo, then create by below commands (assume the folder myfolder is what you want to import, and it’s in C:\test\example\myfolder):

    # in the directory C:\test\example
    git init
    git add .
    git commit -am 'initial commit'
    

    Else, if the folder has already managed in a git repo, skip this step.

  2. Add bitbucket repo as remote for the local git repo

    Use the command git remote add origin bitbucket repo URL> to add the new created bitbucket repo as a remote origin for the local git repo. Such as:

    git remote add origin https://[email protected]/account/reponame.git
    
  3. Push changes to bitbucket repo

    Use the command to push local commit(s) to bitbucket repo:

    git push -u origin master
    

Now the local folder myfolder is pushed to the bitbucket repo successful.

Share:
12,220
Féileacán
Author by

Féileacán

Irish in the heart. Féileacán

Updated on June 04, 2022

Comments

  • Féileacán
    Féileacán almost 2 years

    I'm currently working on a project with some classmates and I want to share code with them, they are not changing the code, they just need it to see how far I've gotten with my work.

    I tried creating a repository on github for that, but they aren't private unless you pay, which I don't want to. I also tried bitbucket, where I can't import local files, only a already existing github repository.

    How can I add local files in Bitbucket OR where can I create private repositorys.

    I don't know much about programming yet and the whole version-control and git topics are new to me.

    • Féileacán
      Féileacán almost 6 years
      @JonathonReinhart That's on github? Because I can't make a private repo on github, only on bitbucket but I can't import a local folder on bitbucket, only a git repo. which wouldn't be private then ...
    • Marina Liu
      Marina Liu almost 6 years
      @Seraphina Does the files in local folder already in a local git repo or not?
    • Féileacán
      Féileacán almost 6 years
      @MarinaLiu-MSFT I don't think so. As I said I don't know anything about git yet. I tried reading some tutorials, as mentioned in the answers but I don't understand it.
    • Marina Liu
      Marina Liu almost 6 years
      @Seraphina I added an answer with the way to check if the local folder in a git repo or not, and the detail steps to push the folder to bitbucket. You can have a try.
    • Marina Liu
      Marina Liu almost 6 years
      @Seraphina Have you get the answer which helps you solve the problem? If yes, can you mark the answer by clicking √ symbol on the left of the answer? And it will also benefit other members who meet similar questions.