简体   繁体   English

合并GIT中的分支-此消息是什么意思

[英]Merging branches in GIT - What does this message mean

In my project I currently have two branches a branch called DEMO and another branch called Master . 在我的项目中,我目前有两个分支,一个叫做DEMO的分支,另一个是Master I am attempting to merge DEMO into Master. 我正在尝试将DEMO合并为Master。 The branch Demo has some files that Demo does not have along with some other changes.In order to do that I am using Source Tree to do the merge. 分支Demo包含一些Demo所没有的文件以及其他一些更改。为此,我使用Source Tree进行合并。 After the merge was done. 合并完成后。 I am assuming it was successful( since I did not get any conflict messages). 我假设它是成功的(因为我没有收到任何冲突消息)。 I attempted to do a commit of the Master branch (with all the merge changes in it). 我试图对Master分支进行提交(其中所有合并更改都发生了)。 At that point Source Tree tells me there is nothing to commit and on the command prompt I get this 那时Source Tree告诉我没有什么要提交的,在命令提示符下我得到了

$ git commit -m "Merge Demo into Master"
# On branch master
# Your branch is ahead of 'origin/master' by 17 commits.
#   (use "git push" to publish your local commits)
#
nothing to commit, working directory clean

My question is if the merge was successful why does it not let me commit the work. 我的问题是合并是否成功,为什么不让我提交工作。 Also what does the message mean ? 该消息还意味着什么?

I'm willing to bet that you've already merged your branches together, and that this was a fast-forward merge. 我敢打赌,您已经将分支机构合并在一起,并且这是一次快速合并。 Your master branch is ahead of the origin by however many commits you had on your previous branch; 无论您在前一个分支上进行了多少次提交,您的master分支都在源头之前。 in this case, it's 17. 在这种情况下为17。

In a fast-forward merge, there's no merge commit, and so no message is generated. 在快速合并中,没有合并提交,因此不会生成任何消息。 This means you're in a good spot to push these changes to the remote. 这意味着您是将这些更改推送到遥控器的好地方。

If you really wanted to create a merge commit before you merged these branches, then you'd need to be explicit about the type of merge you do. 如果您真的想在合并这些分支之前创建一个合并提交,那么您需要明确说明合并的类型。

git merge <branch> --no-ff

This explicitly creates a merge commit, and will open a commit message dialog for you in your editor of choice and allow you to supply a commit message. 这将显式创建一个合并提交,并将在您选择的编辑器中为您打开一个提交消息对话框,并允许您提供提交消息。

When you did the merge, it automatically committed the result. 合并后,它将自动提交结果。 Now you're ready to push your local commits to the remote repository. 现在,您可以将本地提交推送到远程存储库。

Your branch is ahead of 'origin/master' by 17 commits. means you have local commits not yet pushed to the origin. 意味着您有尚未提交到本地的本地提交。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM