Thursday, February 12, 2015

Resolving merge conflicts : Resolve your current index first

Issue:

$ git branch
mydev_repo
* master
I'm trying to switch to mydev_repo branch, but it doesn't allow me to:

$ git checkout mydev_repo
app.js: needs merge
jasmine-test/spec/test-spec.js: needs merge
jasmine-test/src/test.js: needs merge
karma.conf.js: needs merge
package.json: needs merge
error: you need to resolve your current index first

Solution:
1. Reset your git merge
$ git reset --merge
2. Switch to the dev branch:
$ git checkout mydev_repo
3. Discard everything from the master branch and keeping everything from mydev_repo:
$ git merge -s ours master
4. Switch back to the master branch:
$ git checkout master
5. Leaves you with master exactly as mydev_repo was:
$ git merge mydev_repo

Followers