-1

I have inherited a Ruby on Rails project that is currently deployed on a live website. While I have admin control of this project's git repository on Bitbucket, the live instance of the project (that is, the directory structure and all the source files) running on my server appears to have been downloaded rather than cloned.

How do I turn this instance into a proper git checkout referencing the Bitbucket origin and the master branch?

My initial thought was:

cd projectdir/
git init
git remote add origin git@bitbucket.org:my_group/my_project.git
git checkout master

I tested that on another downloaded instance of the project, but this git error is making me think twice:

error: The following untracked working tree files would be overwritten by checkout:
    # a listing of all the files in the project...

There is no difference between the source files in the live instance of this project and what's on the master branch in the repository. However, I do want to minimize my risk of overwriting something important and messing up this instance. I'm using Phusion Passenger with Apache on Mac OSX, and I don't mind bringing Apache down to make the changes. Thanks for your help.

1 Answers1

0

I faced the same problem a while ago, I also received the following

error: The following untracked working tree files would be overwritten by checkout:
index.php
    ...... (too many lines)
Please move or remove them before you can switch branches.

If I remember correctly, the general approach was to just rm the files and then checkout. You could also, add and stash them. Perhaps first consider to force the checkout like:

git checkout --force master

This link (The following untracked working tree files would be overwritten by checkout) saved me a lot of time! It covers more/other details.

Best of luck! :)

Community
  • 1
  • 1
Joey Dorrani
  • 371
  • 1
  • 1