Search code examples
gitgit-branchgit-pushgit-commit

getting update that remote branch has new commit?


Is there a way in git to get an update new commit has been made to the branch by the user?

I have used a command git notify, but it only gives notification if user pulls the branch


Solution

  • I guess a few git clients with a gui will have this option, one of them is SourceTree. It will basically keep checking the repository every so often, in SourceTree by default I think is 10 minutes, configurable.
    If you don't want to use these kind of programs, you could create a script to either run it whenever you want to check the repository given a time frequency. For that:
    Supposing that origin refers to the repository, you would need to do

    git fetch origin
    

    Then, the remote branch origin/master will contain the snapshot of master in the remote repository. Now, you can compare master and origin/master with

    git log master...origin/master
    

    to see the commits that are only in master or origin/master.