Search code examples
gitversion-controlrepositorygit-remote

How can I associate local unversioned code to git remote repository?


I need to associate a clean unversioned code to an existing git remote repository.

I explain better my situation. My project is moved from svn to git. I have a svn local working copy with old code (nothing new to commit) that has to be syncronized with the new git repository. I could clone the repo but I should restore many ignored configuration files by hand and I would avoid it.

So I removed all .svn directories and I would track my code with the git remote repository.

Is there a way to do it?


Solution

  • Ok, I post the right answer for my question based on Adam Dymitruk and Eugene Sajine answers. Thanks everyone for the support :)

    • First of all, remove all .svn directories in working copy directory;
    • initialize new git repository in the working copy directory

      cd /path/to/my/project
      git init
      
    • add git remote repository and fetch it

      git remote add origin url-to-your-remote
      git fetch origin
      
    • reset working copy to remote repository

      git reset --hard origin/master
      

    At the end local repository will be synchronized with remote repository.