How to make my local git copy always at its latest version automatically?

e271p314

My system has few git repositories with some c++ code in them. Users which send a request to my system are getting a binary executable compiled from all the git repositories together. A basic feature of this system is to send binary built from the latest version of the source. In order to do so, each time the system gets a request it runs git pull --all, this command takes a lot of time. I want to avoid running the pull command when a request arrives and instead to make the system run the pull command automatically when the a new version is committed. How to do it automatically?

The only way I can think of is somehow to query the git server periodically every second or so and run the pull command every time there is a new commit in the remote repository but I think that polling is the last solution I'm looking for. Even so, how to implement this naive polling scheme and what alternatives do I got?

VonC

You could put a post-receive hook on the bare repos of your git server, in order for that hook to go to a non-bare repo, and pull.
It would keep that way a working tree always up-to-date, commits after commits.

You can see an example in this question.

#!/bin/sh

unset $(git rev-parse --local-env-vars)
cd /path/to/non-bare.repo
git pull

As illustrated in the follow-up question "Can I issue git rev-parse on remote repository without a local copy?", torek mentions:

You can use git ls-remote to get the head SHA-1s from the remote (including refs/heads/master).
All that will tell you is "same" or "different", assuming you have the head SHA-1s locally.
If they are different, you can't tell precisely why (though you can get probably-enough if you walk the local revs).

Comparing the output of git ls-remote and git rev-parse master will tell me if my local repo is updated or not.

That can be a way to know when to trigger a git pull.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I update git to its latest version on Linux?

From Dev

How to make excel automatically copy specific cells with date on its side

From Dev

How to make oh-my-zsh use the latest zsh version?

From Dev

How to get latest version of git?

From Dev

How to configure the Composer to always download the latest version?

From Dev

How to check if local copy is latest with origin

From Dev

how to make an application that make a copy of its database

From Dev

How can I push and automatically update working copy of my non-bare remote git repository?

From Dev

How can I make my PC always take the first local IP from the WiFi router?

From Dev

Git version always sets prerelase label to "unstable" - how to make it respect config file?

From Dev

git diff between working copy of the file and its version on another branch

From Dev

Can we delete a version from the catalog or copy an older version to make it the latest version?

From Dev

How can I make my program print its github version number with BSD?

From Dev

How to always cherry pick the latest version of a review from gerrit?

From Dev

Can a github repo be made to always refer to the latest version of its submodule repos?

From Dev

Can a github repo be made to always refer to the latest version of its submodule repos?

From Dev

How to update pip3 to its latest version in Ubuntu 18.04?

From Dev

How to install sbt in its latest version in Ubuntu 14.04?

From Dev

Dietpi - How to upgrade my kernel version to latest version

From Dev

Git: How to copy bitbucket master to a local branch?

From Dev

How to make Windows use always the latest CLR for .Net assemblies?

From Dev

How to automatically pull the latest commit from a git submodule on Heroku?

From Dev

How to make a copy of a remote git branch (without merging with my existing branch)?

From Dev

How to make my computer turn on automatically

From Dev

How to make my computer turn on automatically

From Dev

how to make my slider continue its loop?

From Dev

how to make a deep copy of my list

From Dev

How do I make pip display the latest version of a package on PyPI?

From Dev

How to make sure that I use the latest version of bash?

Related Related

  1. 1

    How do I update git to its latest version on Linux?

  2. 2

    How to make excel automatically copy specific cells with date on its side

  3. 3

    How to make oh-my-zsh use the latest zsh version?

  4. 4

    How to get latest version of git?

  5. 5

    How to configure the Composer to always download the latest version?

  6. 6

    How to check if local copy is latest with origin

  7. 7

    how to make an application that make a copy of its database

  8. 8

    How can I push and automatically update working copy of my non-bare remote git repository?

  9. 9

    How can I make my PC always take the first local IP from the WiFi router?

  10. 10

    Git version always sets prerelase label to "unstable" - how to make it respect config file?

  11. 11

    git diff between working copy of the file and its version on another branch

  12. 12

    Can we delete a version from the catalog or copy an older version to make it the latest version?

  13. 13

    How can I make my program print its github version number with BSD?

  14. 14

    How to always cherry pick the latest version of a review from gerrit?

  15. 15

    Can a github repo be made to always refer to the latest version of its submodule repos?

  16. 16

    Can a github repo be made to always refer to the latest version of its submodule repos?

  17. 17

    How to update pip3 to its latest version in Ubuntu 18.04?

  18. 18

    How to install sbt in its latest version in Ubuntu 14.04?

  19. 19

    Dietpi - How to upgrade my kernel version to latest version

  20. 20

    Git: How to copy bitbucket master to a local branch?

  21. 21

    How to make Windows use always the latest CLR for .Net assemblies?

  22. 22

    How to automatically pull the latest commit from a git submodule on Heroku?

  23. 23

    How to make a copy of a remote git branch (without merging with my existing branch)?

  24. 24

    How to make my computer turn on automatically

  25. 25

    How to make my computer turn on automatically

  26. 26

    how to make my slider continue its loop?

  27. 27

    how to make a deep copy of my list

  28. 28

    How do I make pip display the latest version of a package on PyPI?

  29. 29

    How to make sure that I use the latest version of bash?

HotTag

Archive