WHITECOLOR
WHITECOLOR

Reputation: 26142

Github forking new version and merging changes with it

Question about standard git/github workflow procedure I think. But I really understand all that stuff very badly.

  1. A month ago I had forked some project.
  2. I made my branches with changes I need
  3. Original project has changed since
  4. I want to fork new version and add changes that I've made to previous version

How should I do this? The problems I faced:

1) I can not fork new version, when I press fork github redirects me to my current fork of new version, do I have to remove it to have new version?

2) Is it possible some how to apply changes I've made to previous version in some automatically manner?

Upvotes: 1

Views: 79

Answers (1)

Jarrett Meyer
Jarrett Meyer

Reputation: 19573

I think you just need to fetch upstream.

$ git remote add upstream [email protected]:original-user/project-name.git
$ git checkout master
$ git checkout -b merge-upstream
$ git fetch upstream
$ git merge upstream/master

At this point, you have the new version on a branch named merge-upstream. If everything still works from here, you'll want to merge this to your master.

$ git checkout master
$ git merge merge-upstream

Now your master should be all good with the original master. Delete your working branch.

$ git branch -d merge-upstream

You now have a copy. So you can test your changes against the new master. Merge master into your branch to test.

$ git checkout my-feature
$ git merge master

You should now have all of the changes from the original user's master branch merged into your feature branch.

PS: When working on a long-running project, I try to make sure the original master doesn't get more than a day or two ahead of me. In fact, I always add the remote upstream to point to the original user's repository. Then I can pull in upstream changes whenever I need them.

Upvotes: 4

Related Questions