Git update log of a bare repository

793 views Asked by At

I need to regularly extract the git logs for all branches of several repositories. While I could clone them and then perform a git fetch, I thought about saving some disk space and time and only cloning them as bare:

git clone --bare repoUrl

After the clone, all logs and branches are up to date. I can issue git log --all and I can see all the changes up to the clone moment.

However, I am not able to fetch changes from the remote repo when it gets updated. I.e. if I issue: git fetch --all and then git log --all, I don't see any of the change that happened in the remote repo.

How can I update the state of my local repository when the remote receives new commits?

I have tried:

  • git fetch but it doesn't seem to get any update (i.e. git log --all doesn't show any change).
  • git fetch origin master:master only updates the master branch
  • git branch -r doesn't show anything
  • git branch -a shows only the branches available at the moment of the clone
  • git remote -v shows correctly the url of the remote repository.
2

There are 2 answers

0
Fabio On BEST ANSWER

I found the solution reading this answer related to a similar question (I only need to extract the logs, not to pull the code).

After cloning, I've to add:

git config remote.origin.fetch "+*:*"

so that git can keep track of all the branches, even remote ones. Then, issuing git fetch --all --prune and git log --all I can see all the changes.

0
pqnet On

use git log --remotes after git fetch --all to get the log for the remote branches.