1

I am unable to discard local changes. Furthermore, another strange thing is happening where git does not include the two files in the screenshot when I check the code in. It's always these two files.

I tried to doing the "git reset --hard command" several times as well as undoing the changes through the UI but nothing works.

git status shows the two files as being modified git reset --hard say the HEAD has been changed to the commit on the server but nothing happens.

enter image description here

SmokerJones
  • 323
  • 1
  • 2
  • 11

3 Answers3

1

It appears that you are trying to use the wrong Git command to achieve what you want. Git reset command is used to place your HEAD at a specified state and do not discard your changes in your working directory.

To perform this, try using the git checkout command with the name(s) of the file(s) you want to discard, see here

In this case, it will be :

git checkout -- Model/DataModel.edmx -- Model/DataModel.edmx.diagram

EDIT (From comment below) : Otherwise, if theses files are added to the git repository and they don't belong to it, just move or remove them with classics mv or rm commands. Also, git rm is maybe what you need there.

JeuneApprenti
  • 489
  • 3
  • 20
  • 1
    just `git checkout .` would do the trick here I guess. However, it is risky since it will revert all changes in the current directory (and nested directories). – Ulysse BN Apr 24 '19 at 09:24
  • I'm not sure about nested for this but it definitively accomplish what we want here in a shorter way. – JeuneApprenti Apr 24 '19 at 09:28
  • 1
    JeuneAppreti - it's not working. The files are still there. the only thing I'm able to do is to move the files between staged and unstaged status. – SmokerJones Apr 24 '19 at 09:35
  • 1
    @JeuneApprenti - Well, I am very sure about that. You can try it if you don't believe me :) – Ulysse BN Apr 24 '19 at 09:35
  • Apparently there might be some problems with line endings in so I executed command "git config core.filemode false" as suggested by some but it has made no change. – SmokerJones Apr 24 '19 at 09:42
0

These changes were on a development branch. The only way I was able to "discard" these changes was by committing them to the server. I then merged from our master branch into the development branch to everything is nice and equal.

SmokerJones
  • 323
  • 1
  • 2
  • 11
0

I've also experienced this situation when the same file has been committed on Windows with different casings in the file path or name. You'll know if this is affecting you by cloning the repo somewhere else, you'll see something like this:

the following paths have collided (e.g. case-sensitive paths
on a case-insensitive filesystem) and only one from the same
colliding group is in the working tree:

  'FilePath/File.txt'
  'filepath/File.txt'

You can see this Stack Overflow answer for some potential options for fixing it.

Mike Goatly
  • 7,380
  • 2
  • 32
  • 33