I have my git repository on a linux located on the company server. I ssh into my linux machine and edit files there.ProblemThis method is great until I have a good connection to the server. in case of slow connection or even not having a connection I can't access my work and I am not able to do the job.Potential SolutionMaybe I can copy my files from linux server to my local machine disk and then run an script that listen to changes made in my local files and mirror it to my remote server.I am using Git, any solution should cover git files too.In case I'm losing my connection I should be able to continue my work on local files and as soon as connection established script should mirror my changes to remote server.My machine runs Mac OSX Lion.
Sync local files to remote git repository
rsync;git
I'm not entirely sure from the way the question was phrased, but it sounds to me like you might be experiencing some trouble moving from a non distributed version control system (svn, csv, etc.) to a distributed one like git.As it turns out, you get the functionality you want for free in Git! Simply clone your git repo to the computer you want to work from (git clone <remote-repo>), work as normal (code, git add, git commit, rinse and repeat), and then push back to the remote repo when you're done and have a working internet connection (git push origin master or whatever your remote / branch is called if you didn't go with the defaults). Git downloads a full copy of the repo, including all history, by default; so not having an internet connection shouldn't matter. You can just keep working and sync up with your remote machine when the internet comes back on.If you're looking for a way to automatically push every time a commit is made, check out git hooks. The post commit hook is probably what you want. Just navigate to the .git/hooks directory inside your git repo and rename the file post-commit.sample to post-commit, or create it and make sure it's executable (chmod +x post-commit) if it doesn't exist. Now anything you put into this script will be executed right after you make a commit, for instance, you seem to want:#!/bin/shgit push origin masterYou could also use the post-receive hook on the remote machine to do something every time it receives a push from your local repo.EDIT: In a comment you stated that pushing manually won't work; however, git supports pushing via SSH, which is probably how you're managing your server anyways. If not, it can also push via FTP (shudder) and other protocols including HTTP[S] if you configure your server properly. You should probably look into using git this way, as this is how it was designed to be used.