tags:

views:

60

answers:

2

I have a git-cpan-init of a repo which yielded a different root node from another already established git repo I found on github C:A:S:DBI. I've developed quite a bit on my repo, and I'd like to merge or replay my edits on a fork of the more authoritative repository. Does anyone know how to do this? I think it is safe to assume none of the file-contents of the modified files are different -- the code base hasn't been since Nov 08'.

For clarity the git hub repo is the authoritative one. My local repo is the one I want to go up to git hub shown as a real git fork.

+2  A: 

You should be able to add a remote to your existing repository (using git remote add) so that you can fetch the contents of the github repository into your existing repository.

Assuming that you have a commit in your history (call it O) and a commit in the remote branch (call it R) that correspond to the same set of files (e.g. they are both imports of the same release version), then you can just do an 'onto' rebase. Assuming you have the tip of your changes currently checked out:

git rebase --onto R O             # R and O are sha1 ids (possibly abbreviated)

This replays all of your commits since O onto the new R root commit.

Once you've done this, if you are not up to date with the latest remote master branch you can use a normal rebase to get there and git's history tracking will take care that your changes are applied in a way that makes sense.

git rebase <remote_name>/master   # where <remote_name> is whatever
                                  # you called the github remote when
                                  # you used git remote add
Charles Bailey
I `git remote add github <url>`, then, I `git checkout -b new_master`, then I `git reset --hard` that new_master to the HEAD of `github/master`, then I did the `git rebase --onto <sha1 of new_master> <sha1 of old master with my commits>`. This said "First, rewinding head to replay your work on top of it...Fast-forwarded new_master to 78672c96f2eb0717581f53b300c9243a5b446340" but when I view `git log` on my `new_master` I don't see the changes and they aren't in my working dir.
Evan Carroll
all of the rebasing diagrams in `git rebase`, seem to show common roots. This doesn't apply to me. I'm not sure I can rebase an apple onto an orange so to speak.
Evan Carroll
Why did you `reset` onto `github/master`? If you do this then there's no difference between your branch and the sha1 of the new master so the rebase will fast-forward and won't apply any of your changes. You have to rebase while on _your_ branch. The `--onto` tells git to cross branches without a common ancestor, but the onto parameter has to be on the branch that your trying to build on top of and the remaining parameter has to have some commits the can be applied.
Charles Bailey
actually, this did work! thanks a ton!
Evan Carroll
A: 

A Graft Point would help I think.

hash