Question

Git keeps adding the same changeset, which looks like this:

@@ -1,12 +1,12 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="fill_parent"
-    android:layout_height="fill_parent"
-    android:orientation="vertical" >
-
-    <TextView
-        android:layout_width="fill_parent"
-        android:layout_height="wrap_content"
-       android:text="@string/hello" />
-
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:orientation="vertical" >
+
+    <TextView
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:text="@string/hello" />
+
 </LinearLayout>
\ No newline at end of file

The file is not open in any editor, and every time I discard changes by doing a git checkoutor by using the github tool, the changes reappear without me even doing anything. Committing the files changes nothing, the same changeset reappears immediately.

How do I keep it from doing this?

Was it helpful?

Solution

Whole file is always changed? Line endings! (read it as LINE ENDINGS!!!)

You can read git's manual on line ending conversion, Github also as a nice detailed explanation on this, but to put it basically:

  • Your editor should use expected line endings (most people stick with the OS default)
  • Your core.autocrlf in gitconfig should follow the editor's option.

You might need to issue a commit fixing the line issue if you made a commit with the wrong line ending (i.e. the git repo should always be in LF).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top