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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Add existing local project to remote repository

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

0 votes
Ana Retamal Atlassian Team Jul 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
Community showcase
Published in DevOps

Step up your DevOps game webinar Q&A series - Questions answered!

  On October 21st, 2020 we hosted a webinar titled,   Step Up You DevOps Game with 4 Key Integrations for Jira and Bitbucket. We had a great showing and high engagement, but that meant th...

117 views 0 1
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you