0

I have a strange problem. i made changes to my project and committed all changes. immediately after this commit, I copied both the git repository(.git folder) and working directory(my project) into another location. I then run, git status on the original project not the copied one. while i expect working tree clean, i am getting changes not staged for commit, why i am getting this?

git status

output

On branch master Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory)

    modified:   kS_Solutions/My Project/PublishProfiles/mlkfilesys.pubxml.user
    modified:   kS_Solutions/bin/FAMS_Solutions.dll

expected output

Nothing to commit, working tree clean
The Scientific Method
  • 2,374
  • 2
  • 14
  • 25
  • Did you try taking the suggestion and doing `git add` on these files? – Tim Biegeleisen Aug 02 '19 at 09:02
  • 1
    It might (or might not) help if you showed the exact command sequence to reproduce the problem. In particular, how did you do the copying? – torek Aug 02 '19 at 09:04
  • @TimBiegeleisen that is not the problem, i can do it. why i get changes, while i did not change anything, i just copied to another location out of the project – The Scientific Method Aug 02 '19 at 09:04
  • @torek right click copy and then paste somewhere – The Scientific Method Aug 02 '19 at 09:04
  • You haven't staged these two files thus there were not committed. This has nothing to do with the copying to another dir thing. – leopal Aug 02 '19 at 09:05
  • @leopal i just checked it twice, my working directory is clean. i dont know why, i am working on virtual machine – The Scientific Method Aug 02 '19 at 09:06
  • 4
    Ah, so you're using some sort of GUI interface, rather than command-line Git. I'm always suspicious of GUIs: they like to change things behind your back. – torek Aug 02 '19 at 09:06
  • @torek do you know why i am getting that? – The Scientific Method Aug 02 '19 at 09:07
  • No. I try to avoid most of these various GUIs. Too many of them do too many weird things. I don't know what GUI you're using, but if this doesn't occur *outside* the GUI, that points to the GUI doing it. – torek Aug 02 '19 at 09:09
  • 1
    You should have copied the enclosing directory instead. My guess is that you did not copy the hidden _.gitignore_ file at the root of the directory. – Thibault D. Aug 02 '19 at 09:21
  • `ls -al` in the original directory will tell us :) – Thibault D. Aug 02 '19 at 09:22
  • @ThibaultD. there is not *.gitignore* in my directory – The Scientific Method Aug 02 '19 at 10:41
  • I think you need to do some more exploration and tell us the state of your sandbox: 1) if you do `git diff` (on the command line please), what do you see? 2) if you do `git show HEAD`, do you see the last commit you say you did before copying the project? 3) Are those files in the state you expect? – joanis Aug 02 '19 at 12:49
  • 1
    Are you working with your project using an IDE? Is `FAMS_Solutions/bin/FAMS_Solutions.dll` a build artefact? Did you save your project or build after `git commit`? – Leon Aug 05 '19 at 17:21
  • yes with visual studio. i did neither build nor save after a commit. i just copied using right click copy and then paste somewhere – The Scientific Method Aug 06 '19 at 05:07
  • @TheScientificMethod I'd like to give a shot at your bounty, but you didn't answer the questions I asked in my previous comment. What does `git diff` tell you, etc. We'd need to look at your sandbox to help you, and you have to help us help you because we can't look at it directly. – joanis Aug 07 '19 at 00:45
  • @joanis thanks, it shows me differences such that, as if the last commit did not happen. i.e showing difference between changes I made and the previous commit, not the current commit. – The Scientific Method Aug 07 '19 at 04:59
  • I just had a thought: try running `git reflog`. It contains a history of recent Git commands run that affect the repo and sandbox. If the commit happened as you expect, the top line should reflect that, but if some other change happened, that would also be visible. Show us the top few lines, it might shed some light on the problem. – joanis Aug 07 '19 at 13:50
  • @joanis there is nothing i expect. the last commit i made is at the top, no other recent command found. but i am thinking the problem may be associate with type of copy i made, it is OS command. – The Scientific Method Aug 07 '19 at 14:09
  • And what about `git show HEAD`, does it show the last commit is indeed your commit, with the same changes `git diff` also reports? – joanis Aug 07 '19 at 14:11
  • I give up. I think the behaviour your describe should not have happened given what you say you did. The explanation almost certainly lies in something you don't remember having done. I don't expect this problem to be reproducible, either. – joanis Aug 08 '19 at 15:45
  • What is the output of git diff? Please add the output of the command to your question – Tarun Lalwani Aug 08 '19 at 17:07
  • Are you using two different shells to look at the repository? e.g. powershell and bash? – gregory Aug 11 '19 at 04:56
  • @gregory i am using only cmd – The Scientific Method Aug 11 '19 at 11:39
  • @joanis, i jave checked the incident multiple times, i just want to know the reason. – The Scientific Method Aug 11 '19 at 11:40
  • @TheScientificMethod If you still want to know the reason, I don't understand why you resist giving us the output we're asking for. With more information, we might be able to figure it out, but while you answered some questions, you've left several more troubleshooting questions unanswered, including mine. – joanis Aug 11 '19 at 12:00

1 Answers1

1

Truly bizarre! Depending on your OS, I would suggest using one of several approaches to determine if an outside application or process is changing the files. I think you should at least rule out this possibility because the behavior you describe seems unlikely to occur without outside influence.

OSX: See what process is using a file in Mac OS X

Linux/Unix: https://unix.stackexchange.com/questions/13776/how-to-determine-which-process-is-creating-a-file

Windows: https://superuser.com/questions/521476/detect-what-process-is-changing-a-file-on-windows

As others have mentioned, I think it would be difficult to suggest much more without getting more information, but I wish you all the best solving the mystery.

Matt L.
  • 3,431
  • 1
  • 15
  • 28