I don't believe this is possible. I believe you have to clone that remote repo locally and perform git fetch
on it before you can issue a git log
against it.
NB. "origin" below use to represent the upstream of a cloned repository, replace "origin" with a descriptive name for the remote repo. "remote reference" can use the same format used in clone command.
git remote add origin <remote reference>
git fetch
git log origin/master
Here's a bash function that makes it easy to view the logs on a remote. It takes two optional arguments. The first one is the branch, it defaults to master. The second one is the remote, it defaults to staging.
git_log_remote() {
branch=${1:-master}
remote=${2:-staging}
git fetch $remote
git checkout $remote/$branch
git log
git checkout -
}
examples:
$ git_log_remote
$ git_log_remote development origin
This is what worked for me:
git fetch --all
git log production/master
Note that this fetches from ALL remotes, i.e. potentially you "have to clone 2GB worth of objects just to look through the commit logs".
git
isn't a centralized scm like svn
so you have two options:
It may be annoying to implement for many different platforms (GitHub, GitLab, BitBucket, SourceForge, Launchpad, Gogs, ...) but fetching data is pretty slow (we talk about seconds) - no solution is perfect.
An example with fetching into a temporary directory:
git clone https://github.com/rust-lang/rust.git -b master --depth 3 --bare --filter=blob:none -q .
git log -n 3 --no-decorate --format=oneline
Alternatively:
git init --bare -q
git remote add -t master origin https://github.com/rust-lang/rust.git
git fetch --depth 3 --filter=blob:none -q
git log -n 3 --no-decorate --format=oneline origin/master
Both are optimized for performance by restricting to exactly 3 commits of one branch into a minimal local copy without file contents and preventing console outputs. Though opening a connection and calculating deltas during fetch takes some time.
An example with GitHub:
GET https://api.github.com/repos/rust-lang/rust/commits?sha=master&per_page=3
An example with GitLab:
GET https://gitlab.com/api/v4/projects/inkscape%2Finkscape/repository/commits?ref_name=master&per_page=3
Both are really fast but have different interfaces (like every platform).
Disclaimer: Rust and Inkscape were chosen because of their size and safety to stay, no advertisement
A fast way of doing this is to clone using the --bare
keyword and then check the log:
git clone --bare git@giturl tmpdir
cd tmpdir
git log branch
I'm not sure when filtering was added but it's a way to exclude the object blobs if you only want to fetch the history/ref-logs:
git clone --filter=blob:none --no-checkout --single-branch --branch master git://some.repo.git .
git log
You can easily get the log of the remote server. Here's how:
(1) If using git via ssh - then just login to the remote server using your git login and password-- and chdir the remote folder where your repository exists- and run the "git log" command inside your repository on the remote server.
(2) If using git via Unix's standard login protocol- then just telnet to your remote server and do a git log there.
Hope this helps.
git log remotename/branchname
Will display the log of a given remote branch in that repository, but only the logs that you have "fetched" from their repository to your personal "copy" of the remote repository.
Remember that your clone of the repository will update its state of any remote branches only by doing git fetch
. 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.
Perhaps another useful command could be:
git log HEAD..remote/branch
which will show you the commits that are in the remote branch, but not in your current branch (HEAD
).
You can only view the log on a local repository, however that can include the fetched branches of all remotes you have set-up.
So, if you clone a repo...
git clone git@gitserver:folder/repo.git
This will default to origin/master
.
You can add a remote to this repo, other than origin
let's add production
. From within the local clone folder:
git remote add production git@production-server:folder/repo.git
If we ever want to see the log of production
we will need to do:
git fetch --all
This fetches from ALL remotes (default fetch without --all
would fetch just from origin
)
After fetching we can look at the log on the production
remote, you'll have to specify the branch too.
git log production/master
All options will work as they do with log on local branches.
Source: Stackoverflow.com