简体   繁体   English

在Git Bash Windows中合并分支

[英]Merging branches in Git Bash Windows

Below are the things i executed in order in my local Git Bash for Windows 以下是我在Windows本地Git Bash中按顺序执行的操作

  1. I created a new clone from a remote repository 我从远程存储库创建了一个新克隆

  2. I created a new local hotfix branch from master 我从master创建了一个新的本地修补程序分支

    git checkout -b hotfix-1.12 git checkout -b修补程序1.12

  3. Did the changes i wanted on the hotfix-1.12 files 我对hotfix-1.12文件进行了更改吗

  4. I did the commit git commit -m "commit message" 我做了commit git commit -m“ commit message”

  5. Now went back to develop to merge the changes git checkout develop 现在回去开发合并变更git checkout开发

  6. Now i merged it 现在我合并了

    git merge --no-ff hotfix-1.12 git merge --no-ff修补程序1.12

It updated develop without any problem but it doesn't work as expected for master. 它更新了开发,没有任何问题,但无法正常使用。 Below are the respective commands 以下是各自的命令

  1. Back to master git checkout master 回到主git checkout master

8.Merge below doesnt work git merge --no-ff hotfix-1.12 8,下面的合并不起作用git merge --no-ff hotfix-1.12

It says Alredy up-to-date. 它说Alredy是最新的。 But its not. 但事实并非如此。 The changes i made are not reflected when i check. 我所做的更改不会在我检查时反映出来。 Again im doing all this in the Bash in Git for windows. 我再次在Windows的Git中的Bash中执行所有操作。

Do you see anything wrong? 你有什么不对吗? How can I successfully merge hotfix-1.12 into master? 如何将hotfix-1.12成功合并到master中?

You can try several things to figure out (or try to fix) where you went wrong. 您可以尝试几种方法来找出(或尝试解决)哪里出了问题。

  1. Run git log --graph --all '--pretty=tformat:%h %Cred%d %Creset%s' to see what Git has recorded as far as your commits, and on which branch they are. 运行git log --graph --all '--pretty=tformat:%h %Cred%d %Creset%s'来查看Git记录的提交内容以及它们在哪个分支上。 The output is fairly self explanatory, you will see the commit history, along with where all the branches currently are (colored in red). 输出是很容易解释的,您将看到提交历史以及当前所有分支的位置(红色)。 This will show clearly what you merged onto which branch, where they diverge, etc. 这将清楚显示您合并到哪个分支,分支在哪里等的内容。

  2. You can blindly (and destructively) try to merge again: git checkout master; git reset --hard origin/master; git merge --no-ff hotfix-1.12 您可以盲目地(破坏性地)尝试再次合并: git checkout master; git reset --hard origin/master; git merge --no-ff hotfix-1.12 git checkout master; git reset --hard origin/master; git merge --no-ff hotfix-1.12 git checkout master; git reset --hard origin/master; git merge --no-ff hotfix-1.12 ( Warning: this will wipe out your working directory changes, AND your local commits to master which you haven't pushed yet! ) git checkout master; git reset --hard origin/master; git merge --no-ff hotfix-1.12警告:这将清除您的工作目录更改,并且您本地提交给尚未推送的master!

  3. If all else fails, you can reset the master branch ( git reset --hard to reset to the last local commit, or git reset --hard origin/master to reset to the last fetched remote commit) and then git cherry-pick your hotfix commit(s). 如果所有其他方法均失败,则可以重置master分支( git reset --hard重置为最后的本地提交,或者git reset --hard origin/master重置为最后获取的远程提交),然后git cherry-pick修补程序提交。

In any case, do not push the merged branches upstream until you have figured out and performed your merges correctly and fully. 无论如何,在您确定并正确,完全执行合并之前,请勿将合并分支推向上游。

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

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