3

I have a remote GitHub repository named "myRepository". Over there I have two branches: master, and test. I checked out these two branches to my work directories: c:\master, c:\test.

When I am at c:\test I did git merge master and I got an error

merge: master - not something we can merge

Did you mean this?
        remoterepo/master

Can you please explain this error to me? I was trying to merge test to master in my working directory (so c:\master will be update with c:\test code) and then I would like to push the updates to the remote master.

Makoto
  • 104,088
  • 27
  • 192
  • 230
yoav123456
  • 45
  • 1
  • 1
  • 5

3 Answers3

10

It means there is a typo mistake in your branch name.

Nalan Madheswaran
  • 10,136
  • 1
  • 57
  • 42
6

I checked out these two branches to my work directories: c:\master, c:\test.

If the two branches are in separate directories then they're entirely separate repositories. You cannot merge between them.

Having multiple checkout directories in Git means you have multiple clones of the repository sitting in c:\master.git\ and c:\test.git\ respectively. They cannot talk to each other.

Instead, have one clone of the repository you do all your development on and switch between branches with git checkout.

Makoto
  • 104,088
  • 27
  • 192
  • 230
Schwern
  • 153,029
  • 25
  • 195
  • 336
  • yes I though this is the problem ... I am working that way as it easy to me to managed multiply eclipse workplaces(each for git brunch) , each is point to separated git working directory. How should I overcome this desire ? – yoav123456 Mar 10 '17 at 18:16
  • @yoav123456 I don't use Eclipse, so I don't know what Eclipse workplaces are. If it works like any sensible editor, it will notice when you `git checkout` and update accordingly. If it doesn't, get a new editor. I like [Atom](https://atom.io/). The one thing I can say for sure is to get used to Git's style of branching and don't fight it. – Schwern Mar 10 '17 at 18:42
  • git could work on their error messages – java-addict301 Mar 06 '23 at 21:00
0

(Schwern's answer points out the issue with have 2 different locals...this answer is in addition to that answer NOT a substitute for that answer).

..........

For future readers:

Take a look at this other SOF answer:

Merge development branch with master

From that answer : it looks like it has to do with whether you "pull" the second branch. Notice there are 2 pulls in the answer above.

By doing a pull (and thus ("kinda") getting local copies of each branch)...by doing a pull on both branches, you avoid the "not something we can merge" "did you mean this?" error messages. The "kinda" part is that you don't have distinct copies of each branch, you are using git to perform a switch-the-current-branch in the same local directory.

....

Now I am going to post here the code that I am using, but that I reasoned from the answer I include with my answer. In the below my goal is to merge develop into master.

REM below shows the branches
git branch -a
REM below shows the branch are you on
git branch

REM below does a checkout on develop
git checkout develop
REM below, now pull the "develop" branch so that it is local
git pull

REM below does a checkout on master
git checkout master
REM below, now pull the "master" branch so that it is local
git pull

REM below shows the branch are you on, a redundant check just to make sure you're on master
git branch
REM now you should be on the master branch, and the below is going to merge develop into (the branch you are already on), aka master
git merge develop

REM git push origin master

REM the below makes it REAL on the remote server
git  push -u origin master
granadaCoder
  • 26,328
  • 10
  • 113
  • 146