Search code examples
gitcachinggit-pushgit-commitgit-remote

how does Git internally handle git push where no outstanding commits


How does Git internally handle a git push for the case where the local branch is up-to-date with the remote , i.e. no outstanding commits ?

Does Git actually retrieve the latest state from the remote origin to determine that "Everything is up-to-date" --or-- does Git rely on its local cache of the remote origin ?


Solution

  • Git push will check the ref from the remote server (via something similar to git ls-remote and get the hashes from there. If the hashes are the same as the one your branch has then it doesn't need to do anything else and thus will display that message.