Reputation: 51
I thought I had git pretty waxed, but I am a bit stymied with this problem.
Here is the picture: I forked 'develop' branch from a project into my own github repo, cloned to local, created git-flow feature, did stuff and published. All fine.
In the meantime, the original project changed to a new develop branch (call it 'develop2') so my published feature could not be pulled into the main project.
So - on advice - I created a local 'develop2' branch, deleted my local 'develop' branch, pulled 'develop2' from the main project repo, and then merged this with my local feature. All fine, EXCEPT... my personal github repo still has the old 'develop' branch and the feature based on that branch.
So , my question is what do I do now? A couple of options I have considered:
If anything goes wrong though I could get stuck with having to redo a whole lot of stuff which would be tiresome to say the least. any advice from gurus out there?
Upvotes: 5
Views: 1467
Reputation: 77620
You absolutely don't need to redo stuff - Git is well-equipped to deal with this sort of problem.
First, forks on GitHub are the entire repository, so deleting your "'develop' fork" doesn't really mean anything - you just need to bring the upstream develop2
changes into your fork. I suggesting adding a remote called upstream
to easily fetch changes from the repository from which I forked.
Now assuming you added upstream
, a git fetch
should pull down upstream/develop2
into your local repository. I would undo your merge (likely git reset --hard develop~
), create a develop2
branch from there for consistency, then rebase your local develop2
changes onto upstream/develop2
: git rebase --onto upstream/develop2 upstream/develop develop
.
Before:
X---Y---Z upstream/develop2
/
| H---I---J develop, develop2
| /
| E---F---G upstream/develop
|/
A---B---C---D
After:
H'--I'--J' develop2
/
X---Y---Z upstream/develop2
/
| H---I---J develop
| /
| E---F---G upstream/develop
|/
A---B---C---D
Upvotes: 3