date" though there is a difference
I have a git repository with 2 branches: master and test.
There are differences between master and test branches.
Both branches have all changes committed.
If I do:
git checkout master
git diff test
A screen full of changes appears showing the differences. I want to merge the changes in the test branch and so do:
git merge test
But get the message "Already up-to-date"
However, examining files under each different branch clearly shows differences.
What's the problem here and how do I resolve it?
The message “Already up-to-date” means that all the changes from the branch you're trying to merge have already been merged to the branch you're currently on. More specifically it means that the branch you're trying to merge is a parent of your current branch. Congratulations, that's the easiest merge you'll ever do. :)
Use gitk
to take a look at your repository. The label for the “test” branch should be somewhere below your “master” branch label.
Your branch is up-to-date with respect to its parent. According to merge there are no new changes in the parent since the last merge. That does not mean the branches are the same, because you can have plenty of changes in your working branch and it sounds like you do.
This often happens to me when I know there are changes on the remote master, so I try to merge them using git merge master
. However, this doesn't merge with the remote master, but with your local master.
So before doing the merge, checkout master, and then git pull
there. Then you will be able to merge the new changes into your branch.
Say you have a branch master
with the following commit history:
A -- B -- C -- D
Now, you create a branch test, work on it, and do 4 commits:
E -- F -- G -- H
/
A -- B -- C -- D
master
's head points to D, and test
's head points to H.
The "Already up-to-date" message shows up when the HEAD of the branch you are merging into is a parent of the chain of commits of the branch you want to merge. That's the case, here: D
is a parent of E
.
There is nothing to merge from test
to master
, since nothing has changed on master
since then. What you want to do here is literally to tell Git to have master
's head to point to H, so master's branch has the following commits history:
A -- B -- C -- D -- E -- F -- G -- H
This is a job for Git command reset
. You also want the working directory to reflect this change, so you'll do a hard reset:
git reset --hard H
链接地址: http://www.djcxy.com/p/94800.html
上一篇: Git推动不会做任何事情(一切都结束了
下一篇: 日期“,虽然有差异