Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I blow away my attempt to resolve git conflicts

Tags:

git

git-revert

I checked out 'production_branch' then did a merge of 'master_branch for_production_branch' there were massive conflicts. 'production_branch' has been deployed to production. But the conflicts require a more experienced eye. I need to get a critical patch (I will do it by hand) onto the production branch 'production_branch' so I can deploy.

git co 'production_branch'  # => 
lib/tasks/foobar.rake: needs merge
vendor/plugins/acts_as_syncable/lib/active_record/whatever.rb: needs merge
error: you need to resolve your current index first

and

git co 'master_branch for_production_branch'
lib/tasks/foobar.rake: needs merge
vendor/plugins/acts_as_syncable/lib/active_record/whatever.rb: needs merge
error: you need to resolve your current index first

How can I get back to 'production_branch' in my working directory so I can deploy a simple critical fix.

like image 358
Charles Magid Avatar asked Jan 21 '13 13:01

Charles Magid


2 Answers

You can use

git merge --abort

to abort your current merge action and revert to the situation before your started the merge. See git merge documentation for more details.

Note that it will throw away any changes your made, but I suppose this is not a problem in your current situation...

like image 91
Veger Avatar answered Oct 11 '22 14:10

Veger


To blow away all the changes and set to prior to merge

git reset --hard commitsha

Here commitsha is the sha id of git commits. You can use gitk or git log to check state of your branch and figure out commit_sha

Update

or on branch git reset --hard production_branch

like image 25
ch4nd4n Avatar answered Oct 11 '22 14:10

ch4nd4n