简体   繁体   中英

Git: Cannot merge feature branch to the current branch

I create a xxx branch from master and then create yyy from xxx branch. There are 2 files in xxx branch and then I add one file after creatimng the branch yyy. Now I want to apply the changes in the yyy branch to xxx branch by merge but after running the following:

git checkout yyy
git merge xxx

It gives "Already up to date." message, but I do not see the changes on branch xxx, but the changes are seen on the branch yyy. I mean that there are still 2 files in xxx and the added file is not seen.

So, my questions are:

1. Is there any flag, etc that I should do in order to merge these 2 branch?

2. Normally I use Gith Bash in order to run git commands. Is it better Git CMD? And can I use cmd instead of git command lines? I mean is there any pros or cons between them?

It looks like you have the things the other way around. You want to merge yyy to xxx, so you should do:

git checkout xxx
git merge yyy

Git is right in saying that yyy is up to date, when you try to merge xxx, as yyy is based on xxx.

You can have a look at this tutorial:
https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging

I think you have your branches backwards in your commands.

According to this git cheatsheet

$ git checkout [branch-name]

  • Switches to the specified branch and updates the working directory

$ git merge [branch]

  • Combines the specified branch's history into the current branch ...

For your case:

If branch yyy has changes and you want to merge changes into branch xxx :

$ git checkout xxx    --Checkout branch to update
$ git merge yyy       --Merge yyy changes into current branch

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