Reputation: 135
Years ago I created a public repository of a SourceForge project on Github. Back then, the project only supported CVS, so I used git cvs to periodically sync my repository with the original.
There have not been any commits to the CVS repository for a long time, and now I found out that they moved to git as well (albeit on Sourceforge, not Github).
My question is now: How do I merge the changes in the SF git repository into my repository?
What I tried so far:
git fetch upstream
git checkout master
git merge upstream/master
The last step works without error, but git status
tells me that master & origin/master have diverged. Doing a git pull
now results on lots and lots of conflicts ("CONFLICT (add/add)").
Upvotes: 1
Views: 359
Reputation: 60255
If you've simply been rebasing your modifications onto branches imported from cvs, this might be very easy. My first attempt would be to match commits by identifiable text in their commit messages, then try to match patch-ids
Setup: find the current base commit for your work:
currentbase=$(git merge-base master master@{u})
git show -s $currentbase
Now to find a corresponding commit in upstream/master
:
git checkout upstream/master
git show -s :/"some regex for unique-looking text in the $currentbase message"
# and if that's right
newbase=`git rev-parse !git:$` # !git:$ is last arg to previous git command
and if that doesn't work, try finding a commit that applies the same patch:
patchids=`mktemp`
git rev-list upstream/master \
| while read; do
git diff-tree -p $REPLY | git patch-id
done >> $patchids
# hunt up a commit that makes the same changes as $currentbase
set -- `git diff-tree -p $currentbase | git patch-id`
grep $2 $patchids
# and if it finds one
set -- $(!grep) # !grep is whole of last grep command
newbase=$2
However you find it, when you get the right one
git rebase --onto $newbase master@{u} master
git branch -u upstream/master
From there, you can do as usual, plain git rebase
defaults to the current upstream.
Upvotes: 2
Reputation: 1323773
The issue is that the histories of upstream/master and master are completely different (every commit has a different SHA1)
You need to look at the history of upstream/master, and determine which are the commits from the Sourceforge Git repo which are new compared to your own master
history.
Then, you can:
master
branchgit cherry-pick
all those commits from upstream/master
to that new branch (which starts from master
)master
.Upvotes: 0