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.
To import the local folder to bitbucket repo, you can follow below steps.
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
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.
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
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With