So, I have a file, for this instance we shall call it $HOME/Documents/hello.txt. I will write some text inside it:
Hello, welcome to my text file And I will hard-link this file here: $HOME/Documents/Backup/hello.txt.
Okay, great, this is now hard-linked. If I write to the original file, the hard-link will be updated:
echo "Hello again" >> $HOME/Documents/hello.txt cat $HOME/Documents/hello.txt Hello, welcome to my text file Hello again cat $HOME/Documents/Backup/hello.txt Hello, welcome to my text file Hello again Now, my problem is, whenever I open either file (either of the hard-linked counterparts) with lots of programs that create temporary files, it loses its link relationship, and neither file will update the other anymore.
So, what can I do in this situation?
Note: I can not use symlinks in this situation, because I am using my hard link for Github to backup some files, and Git doesn't follow symlinks.
ln -f. There are many nasty problems with updating files in place, so that behavior of the editors (create a temporary new file, and atomically rename it to old name) is the best compromise, as it's the only one which doesn't lead to catastrophic data loss and corruption.