0

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?

Jack
  • 1
  • 21
  • 118
  • 236
  • Did you staged and committed the changes in xxx branch before trying to merge in the second branch ? – Tawfik Nasser Sep 25 '20 at 19:10
  • I am not sure, because I have tried many different things. But if I had done, normally I think I would see the thanges in xxx branch. How can I check this? – Jack Sep 25 '20 at 19:12
  • write $ git status in both branches, tell us what you see – Tawfik Nasser Sep 25 '20 at 19:13
  • @tawfiknasser Get "*On branch yyy. Your branch is ahead of 'origin/yyy' by 1 commit. (use "git push" to publish your local commits). nothing to commit, working tree clean"*. – Jack Sep 25 '20 at 19:15
  • You should merge yyy into xxx. So checkout xxx than 'git merge yyy' – sergzemsk Sep 25 '20 at 19:17
  • @sergzemsk I tried also it before asking and encounter the following message: "merge: yyy - not something we can merge" – Jack Sep 25 '20 at 19:17
  • @Jack try to use: 'git log --all --decorate --stat' to see what's going on – sergzemsk Sep 25 '20 at 19:19
  • Does this help? https://stackoverflow.com/questions/16862933/how-to-resolve-gits-not-something-we-can-merge-error – g_bor Sep 25 '20 at 19:19
  • @sergzemsk I encountered "*error: unknown option `all'. usage: git status [] [--] ..."* – Jack Sep 25 '20 at 19:21
  • @g_bor I am not sure, but do you mean the selected answer of that question? I am not sıre to make master branch because the example in my problem, I do not want to merge with master – Jack Sep 25 '20 at 19:23
  • @Jack my fault, 'git log --all --decorate --stat --graph' – sergzemsk Sep 25 '20 at 19:24
  • @sergzemsk It displays the branches, but how can I use it? – Jack Sep 25 '20 at 19:49

2 Answers2

1

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

pkamb
  • 33,281
  • 23
  • 160
  • 191
g_bor
  • 1,077
  • 6
  • 14
  • I tried also it before asking and encounter the following message: "*merge: yyy - not something we can merge*" – Jack Sep 25 '20 at 19:17
1

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