2

My organization has 100s of Git repos. I like to keep my local clones up to date, so I'd like to know which ones need to be cloned instead of re-cloning everything which takes a lot of time. Is there a command that can tell me the last time a remote repo had an update? On any branch?

I've looked into performing a log query on the remote Git repos, but that doesn't appear to be possible

Hugo y
  • 1,421
  • 10
  • 20
  • 1
    See if [this](http://stackoverflow.com/questions/10312521/how-to-fetch-all-git-branches) answers your question... – War10ck Nov 15 '16 at 21:47
  • 2
    Doing a `git fetch` seems like what you're after but you would have to run it in each repo or create a shell script that would do it for you. – kylieCatt Nov 15 '16 at 21:47

3 Answers3

3

To keep a local repo up to date with contributions from other developers, you should use git fetch and/or git pull. See How to fetch all git branches for more details.

Community
  • 1
  • 1
Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268
3

After the first git clone of a repository you don't need to re-clone it. A simple git fetch will due. You can have a loop that performs git fetch for each repository. If nothing has been changed it will cost almost nothing and will be done in no time, and if it has been changed then the update will be incremental and very quick as well most of the times.

yorammi
  • 6,272
  • 1
  • 28
  • 34
2

Agree with yorammi and Code-apprentice, +1 to both. So just to expand a little...

git fetch will update your local repo with any changes from the remote - but will not merge them.

Then you can use git status to see if there are any changes to merge in.

Then you can do a git merge to merge them in.

OR

git pull does a fetch and a merge, if you don't want to bother doing the checks

code_fodder
  • 15,263
  • 17
  • 90
  • 167