Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tracking upstream svn changes with git-svn and github?

How do I track upstream SVN changes using git-svn and github?

I used git-svn to convert an SVN repo to git on github:

$ git svn clone -s  http://svn.osqa.net/svnroot/osqa/ osqa
$ cd osqa
$ git remote add origin [email protected]:turian/osqa.git
$ git push origin master

I then made a few changes in my git repo, committed, and pushed to github.

Now, I am on a new machine. I want to take upstream SVN changes, merge them with my github repo, and push them to my github repo. This documentation says: "If you ever lose your local copy, just run the import again with the same settings, and you’ll get another working directory with all the necessary SVN metainfo."

So I did the following. But none of the commands work as desired. How do I track upstream SVN changes using git-svn and github? What am I doing wrong?

$ git svn clone -s  http://svn.osqa.net/svnroot/osqa/ osqa
$ cd osqa
$ git remote add origin [email protected]:turian/osqa.git
$ git push origin master
To [email protected]:turian/osqa.git
 ! [rejected]        master -> master (non-fast forward)
error: failed to push some refs to '[email protected]:turian/osqa.git'
$ git pull
remote: Counting objects: 21, done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 17 (delta 7), reused 9 (delta 0)
Unpacking objects: 100% (17/17), done.
From [email protected]:turian/osqa
 * [new branch]      master     -> origin/master
From [email protected]:turian/osqa
 * [new tag]         master     -> master
You asked me to pull without telling me which branch you
want to merge with, and 'branch.master.merge' in
your configuration file does not tell me either.  Please
name which branch you want to merge on the command line and
try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details on the refspec.
...
$ /usr//lib/git-core/git-svn rebase
warning: refname 'master' is ambiguous.
First, rewinding head to replay your work on top of it...
Applying: Added forum/management/commands/dumpsettings.py
error: Ref refs/heads/master is at 6acd747f95aef6d9bce37f86798a32c14e04b82e but expected a7109d94d813b20c230a029ecd67801e6067a452
fatal: Cannot lock the ref 'refs/heads/master'.
Could not move back to refs/heads/master
rebase refs/remotes/trunk: command returned error: 1
like image 936
Joseph Turian Avatar asked May 08 '10 21:05

Joseph Turian


People also ask

Can I use Git and SVN at the same time?

No interaction between them. Just ignore the . git folder for SVN and the . svn folder for Git and you should be fine.

Can you use GitHub with SVN?

GitHub repositories can be accessed from both Git and Subversion (SVN) clients.

What is SVN and Git and in Git why we use branches?

SVN has a Centralized Model. In git every user has their own copy of code on their local like their own branch. In SVN there is central repository has working copy that also make changes and committed in central repository. In git we do not required any Network to perform git operation.

Can Git SVN track a standard Subversion repository?

It provides a bidirectional flow of changes between a Subversion and a Git repository. git svn can track a standard Subversion repository, following the common "trunk/branches/tags" layout, with the --stdlayout option.

What is Git SVN used for?

DESCRIPTION git svn is a simple conduit for changesets between Subversion and Git. It provides a bidirectional flow of changes between a Subversion and a Git repository. git svn can track a standard Subversion repository, following the common "trunk/branches/tags" layout, with the --stdlayout option.

How do I synchronize unintegrated commits with a Git SVN branch?

Prefer to use git svn rebase or git rebase, rather than git pull or git merge to synchronize unintegrated commits with a git svn branch. Doing so will keep the history of unintegrated commits linear with respect to the upstream SVN repository and allow the use of the preferred git svn dcommit subcommand to push unintegrated commits back into SVN.

What is the difference between SVN and Git submodules?

In SVN, a subproject is called an SVN external. In Git, it's called a Git submodule. Although conceptually similar, Git submodules are not kept up-to-date automatically; you must explicitly ask for a new version to be brought into your project.


1 Answers

It looks like, with the exception of your rebase, everything happened as expected, but with a lot more verbiage that you might expect. Here's what I think I would do to create/integrate the bits on a new machine:

  1. Clone your Svn repository. Ideally, I'd like to start with the git repo because it's yours and it's in a known state, but I don't know of any way to initially pull content from Svn than to clone it. I like to add a --prefix=svn/ when cloning so that all of my remote branches from Svn are annotated as such.
  2. Add your origin (just like you've done).
  3. Create a local branch for working. git co -b local-branch svn/branchname. Now you have a nice, local area for playing with stuff.
  4. Ensure that you're on that local branch you just created (you should be).
  5. Pull from Github. You've done this correctly, but ambiguously. To clear up the ambiguity, be explicit: git pull origin master (pull from origin to the master branch).
  6. Rebase from Svn to sync everything up. git svn rebase.

I haven't tried this, but it's a pretty typical workflow and the errors you're getting don't seem to be related to your service of two remotes (Svn and Github). They appear to be a bit more generic and related to your workflow and how you're calling the commands.

like image 54
Rob Wilkerson Avatar answered Nov 25 '22 13:11

Rob Wilkerson