Adding svn-remote to existing git repo

dijxtra

I have a git repo, and my company assigned me an empty svn repo to store my code in. So what I'd like to do is just add that svn repo as a remote to my existing git repo and then push to it.

Now, all git-svn tutorials start with "first clone the svn repo, then add code". That doesn't work for me, since I already have an existing git repo.

I also found some tutorials for importing of svn branches to git repo, but that also is not what I need, I need to import git repo into a svn repo.

I tried to simply do a git svn init http://remote-repo, and then git svn rebase, but that ended with "Unable to determine upstream SVN information from working tree history."

I guess this guy had the same problem, but he got no answers. Any ideas on how to do this?

edit:

I did some additional fiddling, but to no avail. I grafted git history onto svn history and did rebase, but it did not fix the problem. Strange. Here is what I did.

After git svn init I did:

git svn fetch # so now I see the svn history in my git repo - I have two unconnected histories in my repo
git checkout svn-git #checking out svn remote
git checkout -b voracle_svn # putting content of the remote to a branch

Then in gitk I created branch named "graft_child" pointing to my initial git commit (start of my git history) and grafted that onto HEAD of svn branch:

git checkout graft_child # checking out the start of git repo
git reset --mixed voracle_svn #positioning myself to the HEAD of svn remote
git commit -am "Grafting git repo onto svn" #as the message said

Then I added SHA1 IDs of child and parent commits to .git/info/grafts and restarted gitk. Gitk now shows a single history (albeit with messed up dates), graft was successful. I then rebased the svn branch:

git checkout voracle_svn # checking out the branch which points to the HEAD of svn repo
git rebase master

This successfully Fast-forwarded voracle_svn to master, which means I should be able to push my repo to SVN. Or so I thought, because

git svn rebase

again gave me "Unable to determine upstream SVN information from working tree history."

Now I'm really out of ideas.

oldman

Short Answer

You should init this svn repo with some commit by svn client first, like this.

$ touch foobar
$ svn add foobar
$ svn ci -m "init svn repo for git svn can detect upstream"

Long Answer

if svn repo is empty when you git svn clone xxx, git client can't detect the upstream svn information from your working tree history, so you should init your svn repo like above.

Let us suppose your local git repo path is /path/to/git_work_tree, your svn repo url is http://path/to/svn_remote_url.

  1. init svn repo by svn client. $ svn co http://path/to/svn_remote_url svn_work_tree $ cd /path/to/svn_work_tree $ touch foobar $ svn add foobar $ svn ci -m "init svn repo"

  2. git svn clone your svn repo to local. $ git svn clone http://path/to/svn_remote_url git_svn_work_tree

  3. merge your local git repo to git_svn_worktree $ cd /path/to/git_svn_work_tree $ git pull /path/to/git_work_tree

  4. now you finally can commit your code $ cd /path/to/git_svn_worktree $ git svn rebase $ git svn dcommit

HAVE FUN!

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Adding svn-remote to existing git repo

From Dev

Smart-Git: Adding new remote svn branch to existing repository

From Dev

Push existing Git repo to a folder in svn

From Dev

Push existing Git repo to a folder in svn

From Dev

Track existing folder from remote git repo

From Dev

Adding a Remote to a Git Repo Owned by Someone Else

From Java

Git push existing repo to a new and different remote repo server?

From Dev

Push local new Git repo to existing remote repo as branch?

From Dev

Associating an existing Git repository to an existing SVN remote, with no common history

From Dev

Associating an existing Git repository to an existing SVN remote, with no common history

From Dev

Cannot push to heroku after adding a remote heroku repo to my existing local repo

From Dev

How can I import part of an SVN repo into an existing git repo, retaining history?

From Dev

Working with remote repo git

From Dev

Git clone remote repo into another remote repo

From Dev

reassign an existing remote repo to my local repo

From Dev

Migrating a large SVN repo to git

From Dev

Can not push to the SVN repo using git svn

From Dev

Existing git (private remote) repo already exists. No way of getting in contact with previous developer

From Dev

Using GIT with both a GIT remote and an SVN remote

From Dev

Using GIT with both a GIT remote and an SVN remote

From Dev

git sparseCheckout repo pushes full repo to remote

From Dev

git not adding existing folder

From Dev

SVN: how to checkout a repo and erase existing file/dir in the local repo

From Dev

SVN: how to checkout a repo and erase existing file/dir in the local repo

From Dev

Push git alias to remote repo

From Dev

Git remote repo, not showing the files

From Dev

Failure to push to remote repo in Git

From Dev

feasibility of git without a remote repo

From Dev

Error Pushing to Remote Git Repo

Related Related

  1. 1

    Adding svn-remote to existing git repo

  2. 2

    Smart-Git: Adding new remote svn branch to existing repository

  3. 3

    Push existing Git repo to a folder in svn

  4. 4

    Push existing Git repo to a folder in svn

  5. 5

    Track existing folder from remote git repo

  6. 6

    Adding a Remote to a Git Repo Owned by Someone Else

  7. 7

    Git push existing repo to a new and different remote repo server?

  8. 8

    Push local new Git repo to existing remote repo as branch?

  9. 9

    Associating an existing Git repository to an existing SVN remote, with no common history

  10. 10

    Associating an existing Git repository to an existing SVN remote, with no common history

  11. 11

    Cannot push to heroku after adding a remote heroku repo to my existing local repo

  12. 12

    How can I import part of an SVN repo into an existing git repo, retaining history?

  13. 13

    Working with remote repo git

  14. 14

    Git clone remote repo into another remote repo

  15. 15

    reassign an existing remote repo to my local repo

  16. 16

    Migrating a large SVN repo to git

  17. 17

    Can not push to the SVN repo using git svn

  18. 18

    Existing git (private remote) repo already exists. No way of getting in contact with previous developer

  19. 19

    Using GIT with both a GIT remote and an SVN remote

  20. 20

    Using GIT with both a GIT remote and an SVN remote

  21. 21

    git sparseCheckout repo pushes full repo to remote

  22. 22

    git not adding existing folder

  23. 23

    SVN: how to checkout a repo and erase existing file/dir in the local repo

  24. 24

    SVN: how to checkout a repo and erase existing file/dir in the local repo

  25. 25

    Push git alias to remote repo

  26. 26

    Git remote repo, not showing the files

  27. 27

    Failure to push to remote repo in Git

  28. 28

    feasibility of git without a remote repo

  29. 29

    Error Pushing to Remote Git Repo

HotTag

Archive