1

When I clone a specific repository on my local machine a certain file seems to be marked as changed every time. I don't want this file to be changed, but I can't switch branch because of it.

I clone the repository from the remote and then immediately enter the folder and check git status:

    Your branch is up-to-date with 'origin/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:   www/applications/nexus/sources/Purchase/LicenseKey/MdFive.php

When I do a git diff on the file, this is what I get:

    diff --git a/www/applications/nexus/sources/Purchase/LicenseKey/MdFive.php b/www/applications/nexus/sources/Purchase/LicenseKey/MdFive.php
index 915cb4f..8553ac1 100644
--- a/www/applications/nexus/sources/Purchase/LicenseKey/MdFive.php
+++ b/www/applications/nexus/sources/Purchase/LicenseKey/MdFive.php
@@ -22,7 +22,7 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
 /**
  * License Key Model - MD5
  */
-class _MdFive extends \IPS\nexus\Purchase\LicenseKey
+class _Mdfive extends \IPS\nexus\Purchase\LicenseKey
 {      
        /**
         * Generates a License Key

Basically MdFive has been changed into Mdfive.

I've tried to do:

git checkout www/applications/nexus/sources/Purchase/LicenseKey/MdFive.php

But the file keeps being displayed with the same change when I do git status and/or git diff. What is going on here?

I have a Mac with version 2.3.2 of Git. In another environment that uses Git 1.7.1 it doesn't happen.

user1015149
  • 187
  • 1
  • 10

2 Answers2

1
git checkout www/applications/nexus/sources/Purchase/LicenseKey/MdFive.php 
git status 
  modified: www/applications/nexus/sources/Purchase/LicenseKey/Mdfive.php
git checkout www/applications/nexus/sources/Purchase/LicenseKey/Mdfive.php
git status
  modified: www/applications/nexus/sources/Purchase/LicenseKey/MdFive.php 

And it keeps on doing that in a loop...

That means you have a setting (or a content filter driver) which applies a change automatically on checkout.

A common one is an eol (end of line: lf vs. crlf) change, because git config core.autocrlf is set to input instead of false.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

You need a local path for git to know

Try the shorter

git checkout -- .

Alternately

git stash 

Both should clear any local changes

exussum
  • 18,275
  • 8
  • 32
  • 65
  • There was nothing wrong with the path I used in git checkout. This is what happens: $ git checkout www/applications/nexus/sources/Purchase/LicenseKey/MdFive.php $ git status modified: www/applications/nexus/sources/Purchase/LicenseKey/Mdfive.php $ git checkout www/applications/nexus/sources/Purchase/LicenseKey/Mdfive.php $ git status modified: www/applications/nexus/sources/Purchase/LicenseKey/MdFive.php And it keeps on doing that in a loop... I don't understand :| – user1015149 Aug 27 '15 at 22:11