1

We are using SVN from starting of our project ,but recently our team migrated from SVN to GIT repository,but for all this migration work I was totally out of sync because i was working on some of the feature so i was using SVN code base because it was active that time.

Now i made plenty of changes in my local code base and in server SVN repository no more active,is this possible to disconnect the SVN repository and connect same code base to GIT repository so i can commit the my changes into GIT repository? OR I have to manually achieve this and such type of code commit not supported?

Subodh Joshi
  • 12,717
  • 29
  • 108
  • 202
  • There are a number of plugins which let you use SVN concurrently with Git. If you are done for good with SVN, then there should be nothing preventing you from creating a Git repo in your project folder. – Tim Biegeleisen Jun 05 '18 at 05:24
  • @TimBiegeleisen Sorry i am totally newbie in GIT ,Do you mean disconnection from SVN and connect with same code base to GIT Repo is possible with the help of some git tool? – Subodh Joshi Jun 05 '18 at 05:26
  • Possible duplicate of [How can I convert a local clone of SVN repo to git](https://stackoverflow.com/questions/44693526/how-can-i-convert-a-local-clone-of-svn-repo-to-git) – phd Jun 05 '18 at 05:45
  • This is impossible. Local SVN checkout doesn't contain enough information to serve as a repository. There is no history information — it's all on the server. You need a live server or a dump from `svnadmin dump`. – phd Jun 05 '18 at 05:45

1 Answers1

2

If you don't care about the history of those changes done in SVN, you can simply report them in a new clone of your Git repository:

 git clone /url/git/repo afolder
 cd afolder
 git --work-tree=/path/to/SVN/workspace add .

 git status
 # check what was added, you might need to tweak your `.gitignore`
 # especially to ignore any `.svn/` folder

 git commit -m "Import from SVN workingspace"
 git push

(Assuming here you are importing that code on the default master branch)

The idea is to reference the folder where you did your changes in your local SVN working directory, and use that as a git working tree, for Git to detect any change/addition/suppression of files with its own content.


This is not about converting a local SVN working tree to a Git repository.
Here, the conversion was already done, but some concurrent work was also made in the SVN local working directory: the commands above are for importing those changes to the Git repo.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • yes i wont care about the history,my worry only to commit the SVN linked local code to newly created GIT repo. in above command do i need to disconnect from SVN repo? – Subodh Joshi Jun 05 '18 at 05:41
  • @SubodhJoshi Not if you do a fresh clone of your Git repo: that new cloned repo won't have any link to SVN. – VonC Jun 05 '18 at 05:42
  • 1
    @SubodhJoshi I have edited my answer to include the `git status` step: make to to not import *too much* ;) (like `.svn/` folders) – VonC Jun 05 '18 at 05:44
  • so all the local svn code changes will move from there to new GIT local code base via this command `git --work-tree=/path/to/SVN/workspace add` ? – Subodh Joshi Jun 05 '18 at 05:44
  • According to PHD comment its impossible and question also mark as a duplicate. – Subodh Joshi Jun 05 '18 at 05:47
  • @SubodhJoshi As long as your SVN changes are done on the same machine as your cloned Git repository, that means you have a local copy of the workspace. And simple git add as I mention in the answer is enough to import those changes. – VonC Jun 05 '18 at 06:09
  • 1
    @SubodhJoshi phd's comment only make sense if you want to convert a local SVN working directory to a Git repo. Then yes, it is impossible and a duplicate. But that is not what you are asking. You *already* converted an SVN repo into a Git one, but did some concurrent work on your SVN working tree. Since you don't care about the local history of that work, my answer stands. – VonC Jun 05 '18 at 06:13
  • Thanks in that case duplicate tag should be remove from question. – Subodh Joshi Jun 05 '18 at 06:22
  • 1
    @SubodhJoshi don't worry about it. It will disappear eventually. – VonC Jun 05 '18 at 06:25