Is there a reason you don't just keep a clone of the git repo locally and then git push to the Linux machine?
–
JodieCJun 11 '12 at 3:44

I want to have a mirror of files and git info locally. I don't want to touch the git
–
MohsenJun 11 '12 at 3:50

1

That's what git clone is for: to mirror a git repository so you can make your own changes without disturbing the remote git repository. But in your case you would git push back to your Linux server when you were done.
–
JodieCJun 11 '12 at 4:01

I see my changes from an URL that pointing to my server. Pushing manually wont work
–
MohsenJun 11 '12 at 4:18

2 Answers
2

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/sh
git push origin master

You 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.

The Right Way to do this is with pulling/pushing from the server. The question is, how can you automate this? Well, with a little bit of work, you could throw together something that auto-pushed to a separate branch on the server everytime a file is changed?