Reputation: 17
I am a newbie with git and I just forked a repository and did some changes to it. After a while, the main repository's history changed. How can I make, the two repos have the same history?
I know that there will be problems with pull requests if the histories are not the same.
Upvotes: 0
Views: 215
Reputation: 427
There are 3 ways you could do that:
Do a git fetch
then you will want to merge what you fetched with your current working branch, that can be done with git merge origin/master
if you're on master. Then you might have merge conflicts to fix before you can commit and push your changes upstream.
For this one, first branch off using git checkout -b <branch name>
, then commit and push your changes. After that, if you want to do it on your machine, you'll have to update master with the same steps than the first way to do it, just make sure you are on master by doing git checkout master
. After that you can merge the changes you put on another branch back with git merge <branch name>
. Fix the merge conflicts then commit and push. If you want to do it on github or your web repo of choice, you have to first merge master into your new branch if there are merge conflicts: git fetch
then git merge origin/master
, fix the conflicts, commit and push, then use the web ui to do the pull/merge request.
Stage your changes with git add
then git stash
and then update your local branch to the upstream like in the first method, then use git stash pop
, fix your conflicts, commit, and push.
Upvotes: 1