ErikTJ ErikTJ - 1 month ago 13
Git Question

GIT corrupt files (<<<<<<<<HEAD)

I have this in my files after some trouble with VS2012 git-plugin:

using Microsoft.VisualStudio.TestTools.UnitTesting;
<<<<<<< HEAD
using NHibernate;
=======
>>>>>>> dd2c3d7dfe81074e7c5a73f8e4ca2584481a74f1

namespace Controll.Hosting.Tests
{
[TestClass]
public class TestBase
{
<<<<<<< HEAD
protected ISessionFactory SessionFactory;

[TestInitialize]
public void InitializeTestBase()
{
SessionFactory = NHibernateHelper.GetSessionFactoryForMockedData();
=======
[ClassInitialize]
public void InitializeTest()
{
Console.WriteLine("Settings NHibernateHelper.IsInTesting -> True");
NHibernateHelper.IsInTesting = true;
>>>>>>> dd2c3d7dfe81074e7c5a73f8e4ca2584481a74f1
}
}
}


How can i reset my files?

Answer

What you had wasn't trouble but conflicts. This happens when the files are modified by two different persons at the same place (you both add/remove/modify things inside the same lines).

You can simply update your files manually, by deciding to keep everything between <<<<<<< HEAD and =======, or between ======= and >>>>>>>, or some mix of the two. Once you resolve all your conflicts, you just need to commit your changes.

To discard local changes on a file, you can do

git checkout yourfile

or, for all files using

git checkout -- .

You can also decide, for each file, if you want to keep your version or the repository version with

git checkout --ours yourfile # Your version
git checkout --theirs yourfile # Repository version