I have already seen:
git fetch
; gitk --all
"git push --tags
ssh username@host "cd my/repo/path && git show"
"git rev-parse --verify origin/master
will show you the SHA of your local copy of origin/master, and git ls-remote origin master
to get the SHA from the remote."git log remotename/branchname
- You can't connect directly to the server to check the log there, what you do is download the state of the server with git fetch
and then locally see the log of the remote branches."Judging by this, for what I want to do, I have to login via ssh
and run a script on the remote server; but I was hoping for a more 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-only repo which is a clone of the remote. So, the local has a reference to the remote URL in remote.origin.url
(seen via git config --list
).
What I want to do, is run the equivalent of git svn log
(maybe with some post-processing) on the remote, but with the call initiated from the local machine/repo - and get the results, again on the local machine/repo. Of course, git-svn
may not even be installed on the local machine, which means only the remote would be able to understand such a command.
I'd be ready to code a hook for the remote repo - but as far as I can see, hooks can run only at specified events (i.e. pull
, update
...) - you cannot really call them arbitrarily: I remember, once I was developing a post-update
script; and to debug it, I had to set it to return an error always, and then I'd "push" a "fake" commit, which would have run the script, and upon the reception of the error, roll-back the repo -- of course, this is not how I imagine the remote script should run.
Another thing that might be possible is to code an alias for the local repo, which then calls SSH in respect to the remote.origin.url
- maybe that would make the running of git svn log
remotely a bit easier?
In the end, this is my question - what options do I have to run a relatively custom git
command (like git svn log
, or a git
alias defined remotely) on a remote repo, by utilizing to greatest extent possible the data already available in the local repo (that is, I want to avoid writing a bash
script, with repeated hardcoded paths/URLs, that will call ssh
and do whatever necessary on the remote) -- possibly, in a similar manner that a remote post-update
git
hook returns its stdout to the local caller, prefixed by "remote: "?
How to run GIT commands on remote repository - "SSH into the server" or " git fetch ; gitk --all " Run git commands on remote working tree (GIT_WORK_TREE=/path) - the answer is about git push --tags.
When I talk to colleagues about Git, I tell them, that there are only three Git commands that cannot be executed without going to a remote repository once a local repo is initialized (assuming that origin is not on the local machine, of course): git fetch. git pull. git push.
The "remote" command helps you to manage connections to remote repositories. It allows you to show which remotes are currently connected, but also to add new connections or remove existing ones.
The answer here seems to be essentially:
ssh server 'cd /path/to/repo && git svn log'
You can write a little bit of code to get server
and /path/to/repo
from git remote
(assuming your remote is an ssh
type remote). No other context information should be necessary other than what can be easily found in the local git repo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With