Run git commands on a remote computer?

I have already seen:

Judging by what I want to do, I need to log in via ssh and run the script on the remote server; but I was hoping for a bigger git-integrated solution, so let me explain what I want to do.

I have a remote repo which is git-svn; then I have a local git repository which is a remote control clone. Thus, the local one has a link to the remote URL in remote.origin.url (displayed via git config --list ).

What I want to do is run the equivalent of git svn log (possibly with some subsequent processing) on โ€‹โ€‹the remote computer, but with a call initiated from the local computer / repo, and get the results again on the local machine / repo. Of course, git-svn may not even be installed on the local computer, which means that only the remote computer can understand such a command.

I would be ready to encode a hook for a remote repo, but as far as I can see, hooks can only be triggered by certain events (i.e. pull , update ...) - you really can't call them arbitrarily: I remember as soon as I Developed a post-update script; and for debugging it, I had to set it to always return an error, and then I โ€œpressedโ€ the โ€œfakeโ€ commit that would launch the script, and when I received the error, I rolled back the repo - of course, this is not the way I assume that remote script should work.

Another thing that might be possible is to encode an alias for the local repo, which then calls SSH on remote.origin.url - maybe this would make it easier to run git svn log ?

In the end, this is my question: what parameters do I need to execute relative to the user git command (e.g. git svn log or the git alias set remotely) on the remote repo, using as much as possible, the data is already available in the local repo (i.e. I want to avoid recording bash script with repeated hard-coded paths / URL-addresses, which will cause ssh and do all that is necessary on the remote control) - perhaps in the same way that the remote post-update git hook returns its stdout local calling mu, the prefix "remote:"?

+6
source share
1 answer

The answer here looks essentially:

 ssh server 'cd /path/to/repo && git svn log' 

You can write some code to get the server and /path/to/repo from git remote (assuming your remote is an ssh type remote). No other context information is needed other than what can be easily found in the local git repository.

+2
source

Source: https://habr.com/ru/post/972546/


All Articles