I have a couple of source files inside a local git repo. The files have been pulled from a remote git repo. When I do a "$git status" I see the following:
$git status
# On branch master
nothing to commit, working directory clean
However, when I edit any source file (using vim or gedit), ^M always gets added to the end of lines that I add. In other words, after I make the changes I see the following:
$git status
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: sourcefile1.c
#
no changes added to commit (use "git add" and/or "git commit -a")
$git diff sourcefile1.c
...
+ This is a test line ^M
...
I do not know why this is happening but it seems that it is not related to the editor I use nor git itself. I am aware that there is a way to force git to ignore ^M, but I really want to know what is going wrong, why these ^M are being inserted, and how I can stop that from happening.
I am using Ubuntu with Linux kernel 3.11.0
I appreciate any help.