git 恢复本地代码到仓库版本_我如何将本地未版本化的代码与git远程仓库相关联?...

这篇博客介绍了如何将一个包含旧代码的 SVN 本地工作副本与新的 Git 远程仓库同步。首先,删除所有 .svn 目录,然后在工作副本目录中初始化新的 Git 仓库,添加远程仓库并拉取代码。最后,通过 `git reset --hard origin/master` 将本地仓库与远程仓库同步。
摘要由CSDN通过智能技术生成

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值