How does Git identify changing a file?

Asked

Viewed 218 times

4

Example scenario

I have the folder projetos on the server.

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

I did the add, commit and push of everything, for the Gitlab.

Doubts

  • If I change a file on the server, copy that file, and play in the folder empresa of my machine, Git will identify that it has been modified?
    • For date of modification or by content of the archive?
  • This way: copying from the server and pasting on the local machine to do the push, would have no problem at all, correct!?


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

1 answer

3


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

Git usually takes metadata from the file to identify, so the timestamp modification is used. In some cases it can do something more complex up to avoid running conditions. And as far as I know it’s implementation detail. It’s interesting to know, but you shouldn’t rely on this information for any activity that depends on it.

So if copying with older time it might not be able to identify which one was changed, it depends on how you copy to know if the time will be changed or not at the time of copying.

Git works if everything is within the norm, if you play around or make abnormal use of the file system it can screw :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.