Choose one origin as canonical for merge with git

I have a file that was modified in two different repositories and merged in my local repository after a pull. I know that one of the repositories is the actual version that I want, and don't want the merged version of the file. How can I tell git, after the merge has already been applied to the local version, to use one version or the other?


Remotes are just a way for git to fetch commits from somewhere. It's the commits that affect what version of content you see; it doesn't matter where they came from.

Picking a version of a file as "canonical" just means making sure that's the version of the file that's in the canonical repository. The upshot of that is that you probably want to do this in your local repository:

# make sure that origin is the canonical remote
# rename the other one to something else!

# make sure you're up to date
git fetch origin
# check out the desired version of the file
git checkout origin/master path/to/file
# and commit this modification
git commit

This could also be done as part of pulling from origin:

# pull from the default remote/branch, hopefully origin/master
git pull --no-commit
# get "their" (origin's) version
git checkout --theirs path/to/file
# commit the merge
git commit

The --no-commit option tells git to stop before committing the merge which is part of the pull, so that you'll be able to modify the result of the merge then commit it. If there are conflicts (which may be likely in your case), then it would have stopped anyway to let you resolve them.

Need Your Help

How do I write text over a picture in Android and save it?


How can I write text on an image and then save it in Android?

Proximity alert not removing


I added some alert to locationManager. I have problem in removing that alert. When I remove alert, it keeps working and is not removed. Here is the code:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.