Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to add existing non-git project to bitbucket

Tags:

bitbucket

I created a project using angular cli. Project is in directory dw-ng2-app and it has several files generated by angular cli. I want to create a Bitbucket repository for this. My confusion is, when I create a repository in Bitbucket, it gives me 3 options

  1. I create a README and .gitignore file. I cannot use this option as then when I try to sync the local project with repository, I get error that there is no common history
  2. I selected option of starting from scratch. The web page listed the commands I should run to clone and upload, eg git clone [email protected]:username/angularcli.git but this creates a new directory on my local machine named angularcli which has .git directory. I am not sure if I can use this option as my project is in different directory and moving it to angularcli directory might affect it (not sure)
  3. 3rd option is to mention that I have an existing project. Then I am prompted to use the command git remote add origin ssh://[email protected]/username/angularcli.git but that doesn't work as my current project directory is not a git repository

How can I move the angular cli project to bitbucket? Should I have created the repository first and then created angularcli project in the generated directory?

like image 269
Manu Chadha Avatar asked Sep 02 '17 04:09

Manu Chadha


People also ask

How do I upload to Bitbucket without git?

Create a new request. Name the request Bitbucket Upload , select POST as the request type, and Multipart as the content type. At the top, enter https://api.bitbucket.org/2.0/repositories/myaccount/myrepo/src for the URL, replacing myaccount and myrepo with your Bitbucket account and repository name.

How do I add existing project to Bitbucket SourceTree?

If you already have a repository, you can view it in SourceTree. Click New, then Add Existing Local Repository. Select the repository your wish to add, then click Open. Your added repository appears under Local.


2 Answers

There are a couple of ways to do this, but the simplest may be to simply make your current project directory, a git repository.

  1. Go to your project directory

    cd dw-ng2-app

  2. Initialize git repository

    git init .

  3. Add your current project to be tracked

    git add --all

  4. Make your initial commit

    git commit -m "Initial commit for Angular project"

At that point, you can use the third, "existing project" option within BitBucket.

After you've created a new repo there, you can see its URL and use that to track your new repository with your local one

git remote add origin https://[email protected]:7999/yourproject/repo.git 
git push -u origin master

[Here's a complete writeup from BitBucket if you need.][1]

note - I used git add . originally in my example, and BitBucket recommends git add --all. Either of these will work fine in your case. [1]: https://confluence.atlassian.com/bitbucketserver/importing-code-from-an-existing-project-776640909.html

like image 129
slothluvchunk Avatar answered Nov 15 '22 08:11

slothluvchunk


If you've created project using angulat-cli then it automatically created project with git initialisation. It also commits initial changes locally. So you just have to add remote origin and push the content.

-If repository is not initialise as git repository then:

cd dw-ng2-app
git add --all
git commit -m "commit message"
git push -u origin master

-If already initialise with git repository. First of all go to directory dw-ng2-app : cd dw-ng2-app

add remote to your repository.

git remote add bitbucket https://[email protected]/yourproject/repo.git

push the changes:

git push -u origin master

here's master is name of branch in which you want to push the content.

like image 41
user3145373 ツ Avatar answered Nov 15 '22 10:11

user3145373 ツ