How does Git identify a file change?

3

Example scenario

I have the projetos folder on the server.

On my local machine, where I have Git, I created a folder empresa , where I copied all the files from the projetos folder of the server.

I made add , commit and push of everything, into GitLab .

Questions

  • If I change a file on the server, copy that file, and play in the empresa folder on my machine, will Git identify that it has been modified ?
    • By the modification date or by the content of the file?
  • That way: copying from the server and pasting the local machine to make push , would not have any problem, correct!?


(yes, I understand that the most correct would be to have Git on the server, but the question is in this specific scenario, for those who do not have Git on the server)     

asked by anonymous 30.08.2018 / 22:02

1 answer

3

You copy a file from somewhere or edit the file in your repository gives it the same, change is change no matter how it was made.

Generally Git takes metadata from the file to identify, so the timespamp of the modification is used. In some cases it may do something more complex to even avoid race conditions . And as far as I know it's implementation detail. It's curious to know, but you should not rely on this information for any activity that depends on it.

So if you copy with an older time it may not be able to identify that it has been changed, depending on the form you are copying to see if the time will change or not at the time of copying.

Git works if everything is normal, if you make jokes or abnormal use of the file system it can get screwed:)

    
30.08.2018 / 22:27