Today when I tried to merge one of my branch say phuddu to my master, I got some weired messages from git.
ERROR: Merge conflict in app/models/activity.rb
fatal: merge program failed
Automatic merge failed; fix conflicts and then commit the result.
Looks like I crashed into a merge conflict today.
My app/models/activities.rb file looked like following.
# == Schema Info
# == Schema Information
# Schema version: 20090530092020
# Table name: activities
# id :integer(4) not null, primary key
# item_id :integer(4) not null
# user_id :integer(4) not null
# item_type :string(255) not null, default("")
# created_at :datetime
# updated_at :datetime
# id :integer(11) not null, primary key
# user_id :integer(11) not null
# item_id :integer(11) not null
# item_type :string(255) not null
# created_at :datetime # updated_at :datetime
Every chunk of code above within the
reflects the modifications made by other commiter (Oh! why!! why did you do this?) whereas the code within the
reflects the changes made by me. Now to resolve above conflicts we will edit our files according to the need and do the following.
It actually tells the git that conflicts have been resolved in the files. Now just do a commit and you are done.
git update-index <filename>