I'm writing a python script to keep my dotfiles up to date with a repository on GitHub. It copies the dot files into a separate directory ( ~/dotfiles
) so that my home directory is not a git repo. Before copying the files, it does a filecmp.cmp( fileInLocalRepo,fileInHomeDir )
to see if the file has changed since it was last copied into the local repo. Once all the files are updated, if there have been any changes the changed files are pushed to GitHub.
That works fine until I start updating dot files from more than one computer, then older files could potentially overwrite my remote ones. If I pull the files down to my local dotfiles
repo first, filecmp.cmp()
will still say the files are different and the script will overwrite the pulled down file with the local one, then push because it thinks there was a change.
Is there any way I can figure out which file is actually newer? I know that git doesn't preserve update times in file properties, so I can't use that. How can I pull down files from GiHut to a local repo ( ~/dotfiles
) then compare them with the same dot files that are in my home directory to see which of each file is actually newer?