Question

I have 2 branches, development and master. I want to create a new feature on the development branch so I do:

git flow feature start test_01

Which creates a feature branch and switches to this branch. For testing reasons I switch to the development branch and edit file read_me.markdown. I commit this change and push it.

I switch back to the feature branch and edit the same read_me.markdown file on the same line to spark a merge conflict. To finish the feature I do:

git flow feature finish test_01 -r (so it rebases the feature branch)

Now a conflict occurs I fix it using vimdiff with vim-fugitive. I start vimdiff and do “:ls” I pick the remote branch to use. Next I do ":diffget 4" followed by ":diffupdate " and next I just write the file and quit everything “:wqa”

Now the conflict is fixed and a merge occurred and I just simply push my changes.

THE PROBLEM: when doing this I go look at Github for mac tool and see that there are no conflicts and no changes. But when I switch over(checkout) to the master branch and back to the develop branch I get that same merge conflict again?

So I’m wondering what is wrong in my way of working.

Thanks a lot for the help

UPDATE1) The Github tool conflict:

Auto-merging README.markdown
CONFLICT (content): Merge conflict in README.markdown
 (1)

UPDATE2) Tried without rebase same error, no error when checking out the branch only in the Github Tool

UPDATE3)

1) git flow feature start test

2) do changes to develop -> so I can spark a conflict

3) do changes to feature

4) git rebase feature develop

5) Fix changes -> When I want to commit it says “No changes - did you forget to use 'git add’?”

6) git checkout develop

7) git merge feature -> STILL HAVE Merge Conflict on Develop branch

UPDATE4) More Details

1) I am on a new branch develop

2) git flow init

3) git flow feature start enhancement1 -> Feature branch is created

4) git checkout develop

4.1) in File readme.md I add “testtesttest” and commit my work

4.2) tig status

4.2) I set the file readme.md to “changes to be committed”

4.3) I commit this files

4.4) Committed as “commit on develop branch”

5) git checkout feature/enhancement1

5.1) in File readme.md I add “xxxxxxxxx” and commit my work

5.2) tig status

5.2) I set the file readme.md to “changes to be committed”

5.3) I commit this files

5.4) Committed as “commit on feature branch”

6) git rebase feature/enhancement1 develop

First, rewinding head to replay your work on top of it...
Applying: Commit on Develop Branch
Using index info to reconstruct a base tree...
M   README.md
Falling back to patching base and 3-way merge...
Auto-merging README.md
CONFLICT (content): Merge conflict in README.md
Failed to merge in the changes.
Patch failed at 0001 Commit on Develop Branch
The copy of the patch that failed is found in:
   /Users/Vincent/Documents/featureconflicts/.git/rebase-apply/patch

When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".

7) I now have a conflict I will fix it setting the file to the condition of 5.1 (in File readme.md I add “xxxxxxxxx” )

8) Fixed the conflict

9) Did git rebase --skip

10) Switches to my develop branch

11) git flow feature finish enhancement

--> Now everything works great. So it was rebase --skip that was needed.

Was it helpful?

Solution

So the clue to this story was, if conflict occurs:

-> and changes of both branches are needed to be kept - git rebase --continue -> if change of only the feature needs to be kept - git rebase --skip

OTHER TIPS

Are you working in an environment with hundreds people working on the same project? I didn't feel like you do, therefore the blind use of the branching model git flow refers to is a huge overkill. You don't have to jump from branch to branch just for the sake of using branches. Use branches when you need them. So first I'd recommend to drop the flow tool and use just git. In a solo project you can easily develop in the develop branch directly and branch out features only in case if you need to do something else in parallel.

In case if you do use feature branch, here is the sequence that should do the trick:

git checkout -b myfeature develop # creating branch from develop and checking out
commit, commit, commit...
git rebase myfeature develop # resolve conflicts if any
git checkout develop
git merge myfeature # fast-forward
git checkout master
git merge develop # fast-forward
git push # or git push <remote_name> master

This seems to be way more clear and less verbose.

From the latest updates of the OP it is clear that initially he was not finishing the rebase operation properly in case of conflicts. In case of conflicts during rebase you should do:

    `git status` #will provide the the list of conflicting files marking them as 
both modified, so edit them to remove conflicts
    `git add {files}` # to tell git that the conflicts are resolved and you can 
continue with rebase
    `git rebase --continue` # continue rebase operation, by applying next 
patch in line.

depending on the way you resolved conflicts the next patch may cause another set of conflicts if the same piece of code was touched.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top