Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Add existing local project to remote repository

idlevandal69 July 19, 2019

I'm trying to add a project to bitbucket for the first time. I have an Angular project which I have been working on and making commits to locally. I created a repository on bitbucket and tried the instructions I've pasted below to push to that repository. While following the below instructions I got the following error: (I also tried git clone https://myRepository & git pull https://myRepository but I got the error: You've added another git repository inside your current repository.)

 

Error...

! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://(my remote name & repo name).git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

 

The instructions I tried...

Import an existing, unversioned code project into Bitbucket Server

If you have code on your local machine that is not under source control, you can put it under source control and import it into Bitbucket Server.

Assuming you have Git installed on your local machine, then:

  1. Locally, change to the root directory of your existing source.
  2. Initialize the project by running the following commands in the terminal:

    git init
    git add --all
    git commit -m "Initial Commit"
  3. Log into Bitbucket Server and create a new repository.
  4. Locate the clone URL in the nav panel on the left (for example: https://username@your.bitbucket.domain:7999 /yourproject/repo.git).
  5. Push your files to the repository by running the following commands in the terminal (change the URL accordingly):

    git remote add origin https://username@your.bitbucket.domain:7999/yourproject/repo.git 
    git push -u origin master
  6. Done! Your repository is now available in Bitbucket Server

Any help would be greatly appreciated..

1 answer

6 votes
Ana Retamal
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 31, 2019

Hi, welcome to the Community!

This is probably caused because a 'readme.md' file was created on Bitbucket Server and it doesn't exist on your local repository yet, hence the message:

the remote contains work that you do not have locally.

To solve this, you can do a force push instead of the regular push, like this:

git push -f origin master 

Keep in mind, though, that this will delete the 'readme.md' file from Bitbucket Server and you'll need to create it again later.

Hope that helps,

Ana

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events