我如何将本地未版本化的代码与git远程仓库相关联? [英] How can I associate local unversioned code to git remote repository?

查看:537
本文介绍了我如何将本地未版本化的代码与git远程仓库相关联?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将干净的未版本化代码关联到现有的git远程存储库。



我更好地解释我的情况。
我的项目从svn移动到git。我有一个svn本地工作副本与旧代码(没有新提交),必须与新的git存储库同步。我可以克隆回购,但我应该手工恢复许多被忽略的配置文件,我会避免它。



所以我删除了所有的.svn目录,我会跟踪我的代码git远程仓库。



有没有办法做到这一点?

好吧,
我根据 Adam Dymitruk Eugene Sajine 的回答。感谢大家的支持:)


  • 首先,删除所有 .svn 工作副本目录中的目录;
  • 在工作副本目录中初始化新的git存储库

      cd / path / to / my / project 
    git init


  • 添加git远程仓库并获取它

      git remote add origin url -to-your-remote 
    git fetch origin


  • 重置工作副本到远程存储库

      git reset --hard origin / master 




最后,本地存储库将与远程存储库同步。


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?

解决方案

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.

这篇关于我如何将本地未版本化的代码与git远程仓库相关联?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆