问题
I have forked a repository from github - it's called bootstrap.
I've cloned my fork:
git clone https://github.com/Fowowski/bootstrap.git
The bootstrap project has a master branch and a 3.0.0-wip branch - ill be working on 3.0.0-wip
So next thing I do (since im on master and its a 2.3.x stable) is switch to 3.0.0-wip and add a remote:
git checkout 3.0.0-wip
git remote add upstream https://github.com/twitter/bootstrap.git
and now im making some changes in the 1 file... after few days when I finished I realised that there were some changes in the 3.0.0-wip and my forked repository is no longer actual.
How should I update my forked repository to make it as clean as it may only be for pushing it in pull request? I heard that I should do fetch/rebase.
I did pull
via tortoise git one time and after I pushed there were few commits that wasnt mine in my pull request... - you can see it here: https://github.com/twitter/bootstrap/pull/7641#commits-pushed-2eb9053 - Im assuming that I didnt do something important but dunno really what.
I did some research about my issue and I found that I should probably run:
git fetch upstream
git merge upstream/master
git push
My problem is - and thats the part that I dont understand most about git: git merge upstream/master - I cant do merge upstream/master because master is bootstrap 2.3.x not 3.0.0-wip? Am I missreading this command or what?
Could you please tell me how can I properly update my forked repository via git bash? What are the proper steps that I need to run after I changed files in my cloned fork repository?
回答1:
The fetch / rebase idea is good, especially if you don't have pushed already your work:
git fetch
# Assuming you are in the right 3.0.0-wip
git rebase upstream/3.0.0.-wip
You could even do it quicker with a pull --rebase:
git pull --rebase upstream
回答2:
It sounds to me that instead of git merge upstream/master
you should do
git merge upstream/3.0.0-wip
(BTW, as you have been advised, it is probably a better idea to do a git rebase
)
来源:https://stackoverflow.com/questions/16199254/update-of-forked-repository-on-github