Sync files with server using git

Git is new here. Is there a way to synchronize the two repositories, so that the current checked files will be the latest version of all the changes?

What I have:

Desktop Server ------- ------ Change_X Change_Y 

And I would like to introduce some “magic” command, and then the changes will be merged

 Desktop Server ------- ------ Change_X Change_X Change_Y Change_Y 

One of the problems is that the desktop is a Windows machine behind NAT, and I would like for me to not have sshd settings. Basically, I would like to do all this using ssh from the desktop to the server.

It seems like this should be trivial with git, but I couldn't figure out how to do this.

(I thought git push would do the trick, but it turns out that it does not make changes to the current branches, so changes from the desktop do not get to the server)

Is there a way to do this with git, or am I disconnected from the track?

Solution: I downloaded the post-update script from here and put it in the hooks directory on the server, and now git push forces the server to update with the changes. Therefore, basically the “magic team” decides:

 git pull server:scripts/ master git push server:scripts/ 

( scripts is the folder I'm syncing to)

+4
source share
2 answers

It should be possible to create a post-commit hook that will update the working copy of the server when changing (I did the same with mercurial, so I assume this is possible with git as well). therefore, after clicking the button, the working copy will be automatically updated.

create a post-commit hook that will run git up or any equivalent command for git.
Sorry, I don’t know what else to say.
upd : there are some explanations in the official git faq .

+3
source

One of the problems is that the desktop is a Windows machine behind NAT, and I would like for me to not have sshd settings. Basically, I would like to do all this using ssh from the desktop to the server.

This is not a direct answer to your question, but if you are behind NAT, the easiest way is to start a reverse SSH tunnel using Putty or something instead of the sshd server.

 ssh -R3333:127.0.0.1:9418 <user>@<server> 

Now connections to port 3333 <server> will be redirected to your git mail server.

+1
source

All Articles