When a file is open in an editor (say Sublime or Atom), and the file is edited outside the editor, the editor invariably refuses to refresh the file it displays. This situation occurs rarely, as most likely one will only use a single tool to edit the file in a particular time frame. This is obviously not an issue when the file is read only. For example, when reading a system error log, the file will be updated as the system is running and may have a new error log, but the log file will not be edited so it does not cause a conflict.
However, it causes problems when the file is updated by git pull
.
When a person pulls the latest updates to the repo, he might have a file open in an editor to which some changes have been made in the update. If the editor fails to refresh the file, the file is saved with the old contents, and any new changes are lost.
Sometimes, it is just annoying to reverse hunk using sourcetree, but when there are a number of files updated, that overwrite may be pushed to git server unnoticed — until an error occurs. Currently we are using git log --follow -p -- file
command to locate and revert the error, but it is not possible if the overwrite is not noticed in time,forcing us to copy the lines manually. Is there a way to prevent this kind of overwrite in the first place?