Thursday, February 8, 2018

Windows file explorer cached hostname specified in hosts file

The 'hosts' file in Windows allows user to add hostname to IP entries. When you modify the entries in hosts, the file explorer might not reflect the changes immediately. This is because the mapping is already cached in the Workstation service.

Consider the following situation, you may hosts file with the following entry:

192.168.1.100   my_nas

Then you can use \\my_nas\share in the file explorer to view content in \\192.168.1.100\share. Next, you try to modify the entry as following:

192.168.1.101   my_nas

While the command ping my_nas tells you my_nas is now 192.168.1.101, but the file explorer cached the entry, hence \\my_nas\share still points to the old IP (i.e. 192.168.1.100).

To clear this cache, apart from rebooting the machine, user can consider to restart the "Workstation" service instead.




Sync multiple git repo at once

Use the following command in Linux will do the job:  ls -d RepoNames* | xargs -I{} git -C {} pull