Editing the hardlink doesn't edit the original file

I have a file at D:\JavaScript\CheckIban.js, and I want to reuse it in many places without duplicating it. Because when I fix a bug (change its content) I need that change to be propagated to all files. Using links my plan is to change one instance of the hardlinks, and expect other instances to be updated automatically.

Now, let's say that I've create a hardlink to this file using:

mklink /H D:\Projects\Crm\Site\Scripts\CheckIban.js D:\JavaScript\CheckIban.js

and I get the success message that the hardlink is created for ...

However, when I open each file and change it, the content of the other file is not changed. What do I miss here?

Notes: I can't use soft links, because I'm using a program (TFS) that doesn't support working with soft links.


There's a difference between changing the file and replacing the file. According to this Microsoft page on Hard Links and Junctions, "Any changes to that file are instantly visible to applications that access it through the hard links that reference it." However, consider what happens when you replace a file: the file system deletes the file (in this case the hard link), then writes the new file with the same path and file name as the former hard link.

So it depends on how the program you're using to change the file writes to the file system when it updates the file.

See also What operations breaks the hardlinks