简体   繁体   中英

Merging branches in Git Bash Windows

Below are the things i executed in order in my local Git Bash for Windows

  1. I created a new clone from a remote repository

  2. I created a new local hotfix branch from master

    git checkout -b hotfix-1.12

  3. Did the changes i wanted on the hotfix-1.12 files

  4. I did the commit git commit -m "commit message"

  5. Now went back to develop to merge the changes git checkout develop

  6. Now i merged it

    git merge --no-ff hotfix-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

8.Merge below doesnt work git merge --no-ff hotfix-1.12

It says Alredy up-to-date. 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.

Do you see anything wrong? How can I successfully merge hotfix-1.12 into 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. 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 ( Warning: this will wipe out your working directory changes, AND your local commits to master which you haven't pushed yet! )

  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).

In any case, do not push the merged branches upstream until you have figured out and performed your merges correctly and fully.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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