1

I'm on local branch master without any staged/unstaged changes. I do git pull origin master and pull some .svg font files from remote, added by other developer.

I write git status and I get these .svg files as 'Changes not staged for commit'.

# 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:   public/fonts/pdf/x.svg
#       modified:   public/fonts/pdf/y.svg
#       modified:   public/fonts/pdf/z.svg
#       modified:   public/fonts/pdf/a.svg
#

no changes added to commit (use "git add" and/or "git commit -a")

They weren't changed by me so I do git checkout --:

M       public/fonts/pdf/x.svg
M       public/fonts/pdf/y.svg
M       public/fonts/pdf/z.svg
M       public/fonts/pdf/a.svg

then git status and the files are still on the list.

I'd like to remove the files from the list and discard any changes because I didn't touch them.

Am I donig something wrong with git or is it possible that there's some background process that changes these files whenever they're reverted to their original state?

git diff:

--- a/public/fonts/pdf/x.svg
+++ b/public/fonts/pdf/x.svg
@@ -1,1403 +1,1403 @@

It seems to be replacing a file with its copy and treating this as a change? I'm now Win8, the files were created on Linux and added to repository on Mac...

Branches:

  checkout-hotfix
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master

Gitignore in 'fonts' directory:

pdf
.gitignore

Gitignore in 'pdf' directory:

*
Alan
  • 1,322
  • 1
  • 21
  • 36
  • 1
    Reset your working tree `git reset --hard HEAD` – Sajib Khan Apr 06 '17 at 09:04
  • 1
    It could be that the line endings are now different. Try doing a compare with some tool that can show you the line endings - or look using a hex editor or something like this. Also you can look at the log to see what changes you are expecting to pull down (nice way to look it is `git log --graph --all --decorate --one-line`, this should highlight where each branch is at (i.e. master vs origin/master) - maybe print this on your question so we can see it... It's probably worth keeping up-to-date with the remote because at some point you will have to merge... – code_fodder Apr 06 '17 at 09:09
  • @sajibkhan thanks but it's still the same. HEAD moves back to the last commit but flies still show on `git status` as modified. – Alan Apr 06 '17 at 09:30
  • 1
    Normally you can just do `git checkout ` so try `git checkout public/fonts/pdf/x.svg` for one file. But you should also be able to do `git checkout .` to revert all your local working files... – code_fodder Apr 06 '17 at 10:03
  • @code_fodder thanks. neither `git checkout .` nor `git checkout public/fonts/pdf/*.svg` helps. Status stays the same. I added .gitignore in the fonts folder with `pdf` in it, then reapplied the other commands - no luck. I saved raw file from remote repository(bitBucket) and then compared it to the local file in Notepad++ - both have endings CRLF. I may need to commit and push, but then other devs may run into problems later. – Alan Apr 06 '17 at 10:24
  • Can you try `git branch -a` to show all branches local and remote and check you are on the correct branch (should have a start * next to it). Also look at the log (see my first comment) which you can view what is going on...maybe add that to the end of your question. Something strange is happening if you can't revert these files. Also while you are there print out your .gitignore... but to be honest if it was ignoring these files I would not expect them to be displayed in your status message... – code_fodder Apr 06 '17 at 10:49
  • @code_fodder sorry, I can't add my log for confidentiality reasons. I've added branches and contents of the .gitignore file. I also followed advice in this post - http://stackoverflow.com/questions/1753070/git-ignore-files-only-locally . *.svg files disappeared from `git status` but then I couldn't checkout my other branch - `error: Your local changes to the following files would be overwritten by checkout:` and then the list of *.svg files. – Alan Apr 06 '17 at 11:08
  • @code_fodder I've just made a copy of the original files, commited these changes and pushed them to remote. Now I can checkout other branch. In case they don't work later I'll try to revert commit or just use original copies. Once again thanks for your assistance :). – Alan Apr 06 '17 at 11:18
  • @Alan sorry was on lunch... yeah, it sounds a bit strange, you definitely have (or had) some local changes which means it won't allow you to checkout another branch, but I can't see why git is not reverting them for you with checkout. I wonder if its one of the following: file attribute change (e.g. read-only), its open by another application, or something like this.... – code_fodder Apr 06 '17 at 13:05

0 Answers0