Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import local folder in bitbucket

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.

like image 706
Féileacán Avatar asked Oct 20 '25 04:10

Féileacán


2 Answers

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.

like image 78
Marina Liu Avatar answered Oct 22 '25 02:10

Marina Liu


First, must init repository in your main project folder.

git init

Add your project files to the Git repo -

git add .

git commit -m "first commit"

Then create repository on BitBucket.org. Also your must create pair of keys for git client, so you can push changes.

After adding public key to BB, Rub this:

git remote add origin [email protected]:<org or user>/<repo name>.git

Where:

  • <org or user> use your Bitbucket account's name (or team/organisation),
  • <repo name>user repository name.

Example: https://bitbucket.org/user/simple-repository - link to User's repository, called "simple repository".

git remote add origin [email protected]:user/simple-repository.git

I almost forgot. After that run:

git push -u origin master

This will push all your files to remote repository.

like image 43
Vapiesz Avatar answered Oct 22 '25 03:10

Vapiesz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!