Android Studio, Git and three ways merge

24,722

Solution 1

First checkout the branch you want to merge other branch(example if you want to merge the development to master then checkout master).

Right click on the branch which you want to merge to your checked out branch and use merge.

If you worked on the same files in the two branches it can't merge itself, hence throws a conflict.

Resolve the conflict manually

Add files to index(This will make it understand that conflicts are merged)

Commit the changes of the merge

Push to your remote.

Solution 2

Add option is disabled

If you are referring to the "Add to VCS" option, it should be disabled as the file is already tracked by git (it is for new files)

Try a commit instead and select the files you have resolved for addition/commit from the commit change dialog.

Share:
24,722
GPack
Author by

GPack

Updated on April 18, 2020

Comments

  • GPack
    GPack about 4 years

    On Android Studio, I created a new branch from the master and commited the new branch two times. Then I checkedout the master and commited it one time. So I have two branches with two distinct endpoints and a common parent. Now I am trying a three ways merge: right click on the new branch, click on the new branch name, then merge, but appears a popup

    Couldn't merge TestMergeBranch CONFLICT (content): Merge conflict in (... files' list ...)

    and nothing more happens.

    Thus I click on VCS menu, Git, Resolve conflicts. Then I click Accept Yours button to resolve the conflicts on selected files. The Resolve window disappears, and again nothing more happens.

    Thus I go to re-add to stage the resolved files but the Add option is disabled.

    Any hints?

    (Android Studio 2.0 on Ubuntu 14.04)

    --- It needs an android-studio-git Tag ---

  • GPack
    GPack about 8 years
    The problem comes after conflicts resolving: there is no way to add to stage, Add option in the menu is disabled.
  • GPack
    GPack about 8 years
    I am referring to the Add option to tell Git that those files are resolved. As you say I will try a commit instead, without adding resolved files before.
  • GPack
    GPack about 8 years
    Tried, commit after resolving conflicts doesnt work, it says: "to make partial commit is impossible while a merge" (translation from localized version).
  • VonC
    VonC about 8 years
    @GPack Check if any of your file has still merge markers in it? (>>>> and <<<<)
  • GPack
    GPack about 8 years
    I dont know how to check it.
  • GPack
    GPack about 8 years
    Git status says: Changes to be committed: modified --- (1 file name)---. It is the same file on which I resolved the conflict, accepting the branch version. I see the accepted version in local files too, and i see the same version in Show Diff in Android Studio. But the commit get the above error.
  • VonC
    VonC about 8 years
    @GPack Just for testing, a git add . and git commit would work from command line?
  • GPack
    GPack about 8 years
    it worked from command line, I would like understand the Git plugin workflow in Android Studio too