7

I just cloned a project using git and opened a new branch. After changing just 1 file I tried to commit the changes but it shows me that I am commiting like 3000+ files. After clicking on any file to see the differences, the phpstorm says "no differences".

I heard that might be an error related to line endings but I have no idea what to do actually right now. Could you please help me? It is impossible to verify 3000 files right now, and I dont want to destroy the project by pushing something crazy.

I tried changing line endings in phpstorm to LF (unix) and CRLF (windows) but it doesnt help at all. I heard it might be necessary to also change it in git, so I tried to run some random recommended commands but no results at all.

EDIT: added 100 reputation bounty. I cannot resolve this problem

SOLUTION: Okay, looks like it was privilege issue. I gave chmod 777 on all directories and it was too much.

divHelper11
  • 2,090
  • 3
  • 22
  • 37

9 Answers9

5

Check the nature of the diff.

For eol, try:

git -c color.diff.whitespace="red reverse" diff -R -- afile

If that is the case, clone again your repo after a

git config --global core.autocrlf false

Check also for any text=auto directive in a .gitattributes file.


For file permission mode, clone again your repo after:

git config --global core.filemode false

You can see the difference with git diff, as I mentioned in this answer.
Note that since Git 2.9.1, you can change the permission of a file with

git add --chmod=+x -- yourFile
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
3

You can check whether your project employs a linting tool or not. If you are in a Javascript environment, you could leverage either ESLint or JSLint. In the config file for your linting tool, check to see what type of line-endings are defined.

For Windows, \r\n is defined for CRLF.

For UNIX, \n is defined for LF.

Make sure the correct line-endings are set up in your project as these can lead to the issue you are having.

In PhpStorm you can also go to Editor>Code Style and see what type of settings you have defined under Line separator.

A deviation in the line-ending scheme between the remote branch and your local environment may lead to committing several unwanted files that you have not modified.

ValyriA
  • 157
  • 2
  • 9
3

You can check HTML, CSS, JS code formatting that can be auto-formatted by your IDE (e.g. 4 space -> 2 space or reverse). Check also line ending for Windows/Linux machine.

  1. One solution is to save your one file changes (modified file) somewhere.
  2. Close your IDE. Use terminal.
  3. Then undo (hard reset: would be removed all changes) your last commit.

    $ git reset --hard HEAD~1
    
  4. Then replace the file with the modified file. (using terminal or operating system GUI)

  5. Then git add & commit

    $ git status                  # see difference between working directory and the index
    $ git commit -am 'message'    # add & commit 
    
Sajib Khan
  • 22,878
  • 9
  • 63
  • 73
2

do you do something with file permissions? I think this may be the problem.

try compare single file:

git diff mybranch master -- myfile.cs

If it will be the permission problem you will get something like this:

old mode 100755  
new mode 100644 
lucio
  • 29
  • 3
0

You may need to add a line or two to your .gitignore file. Here's an example of some of the project files that are created by my IDE and OS that I don't want to commit. These lines are listed in my .gitignore file.

# Package Files #
*.jar
*.war
*.ear

### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
*.iml
.idea

### OSX ###
.DS_Store
.AppleDouble
.LSOverride
Jake Henningsgaard
  • 704
  • 1
  • 6
  • 16
0

Cancel the commit, or commit to a separate branch and then make a pull request to master.

Giacomo
  • 156
  • 1
  • 16
  • But is this normal behavior that Im commiting 1400 files that I never changed myself? Im commiting on my branch right now but it is going through all these files, thats insane – divHelper11 Dec 05 '16 at 14:42
0

If you have done a git init in local and did a git clone inside the folder where you did git init, then it will show all files as uncommited and untracked as your local git is unaware of those files.

this happened to many developers who do git init as well as git clone.

Solution:

    • delete git init
    • clone the url

should work. I am not sure if you have done the same, but its one of the case.

IamK
  • 2,753
  • 5
  • 30
  • 39
TULSI JAIN
  • 99
  • 6
0

There might be something magical, So all you need to do is after checking out that branch first do git checkout . and git clean -f . then apply your changes.

Parmatma
  • 191
  • 10
0
git checkout .
git clean -f
git reset --hard
git clone

OR

Your editor indentation configs must be different, like space/tabs or tab size, or html/css preferences and hence showing differences caused by a different indentation.

Shreya Batra
  • 730
  • 1
  • 6
  • 15