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?
Assuming all the computers you are setting this up on have accurate times, you could have it create a timestamp file for each dotfile, which just contains the local modified time of the dotfile. Then you can compare the local timestamp with the remote one.
You could also just do the commit locally and try to merge with the remote branch. If the merge succeeds then assume it's ok. If it failed then there were two different changes to the same part of a file and the conflict needs to be resolved, in which case you notify yourself somehow.
A potentially simpler and less error prone solution (because it's more manual) would be to have your dotfiles be symlinked to the dotfiles in the git. Then when you edit a dotfile the git one is updated, and you can manually commit and push the change easily.
Best way to compare remote git file versions with local file versions?