git Git合并开发到功能分支输出“已经是最新的”,而它不是
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33342357/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git merge develop into feature branch outputs "Already up-to-date" while it's not
提问by MeesterPatat
I checked out a feature branch from develop called branch-x
. After a while other people pushed changes to the develop branch.
我从开发中检查了一个名为branch-x
. 过了一会儿,其他人将更改推送到开发分支。
I want to merge those changes into my branch-x
. However if I do
我想将这些更改合并到我的branch-x
. 但是,如果我这样做
git merge develop
it says "Already up-to-date" and doesn't allow me to merge.
它说“已经是最新的”并且不允许我合并。
git diff develop
shows that there are differences between branch-x
and develop.
git diff develop
表明存在差异branch-x
和发展。
How do I merge develop into branch-x
?
我如何合并发展到branch-x
?
回答by Maroun
You should first pull
the changes from the develop
branch and only then merge them to your branch:
您应该首先pull
从develop
分支更改,然后才将它们合并到您的分支:
git checkout develop
git pull
git checkout branch-x
git rebase develop
Or, when on branch-x
:
或者,当开启时branch-x
:
git fetch && git rebase origin/develop
I have an alias that saves me a lot of time. Add to your ~/.gitconfig
:
我有一个别名,可以为我节省很多时间。添加到您的~/.gitconfig
:
[alias]
fr = "!f() { git fetch && git rebase origin/""; }; f"
Now, all that you have to do is:
现在,您所要做的就是:
git fr develop
回答by Linga Swamy Parandha
Initially my repo said "Already up to date."
最初我的回购说“已经是最新的”。
MINGW64 (feature/Issue_123)
$ git merge develop
Output:
输出:
Already up to date.
But the code is not up to date & it is showing some differences in some files.
但是代码不是最新的,并且在某些文件中显示了一些差异。
MINGW64 (feature/Issue_123)
$ git diff develop
Output:
输出:
diff --git
a/src/main/database/sql/additional/pkg_etl.sql
b/src/main/database/sql/additional/pkg_etl.sql
index ba2a257..1c219bb 100644
--- a/src/main/database/sql/additional/pkg_etl.sql
+++ b/src/main/database/sql/additional/pkg_etl.sql
However, merging fixes it.
但是,合并修复了它。
MINGW64 (feature/Issue_123)
$ git merge origin/develop
Output:
输出:
Updating c7c0ac9..09959e3
Fast-forward
3 files changed, 157 insertions(+), 92 deletions(-)
Again I have confirmed this by using diff
command.
我再次使用diff
命令确认了这一点。
MINGW64 (feature/Issue_123)
$ git diff develop
No differences in the code now!
现在代码没有区别了!
回答by Sebastian Diez
git fetch && git merge origin/develop
回答by Paul-Arthur THIéRY
git pull origin develop
Since pulling a branch into another directly merges them together
由于将一个分支拉入另一个分支直接将它们合并在一起