Search code examples
gitgit-pull

How to download updates made before a time point from remote server by git


Git remote server may have many updates for a repo, if I just want to download the updates for this repo, which were made before a time point, what git command should I use?


Solution

  • There is, in general, no single command for that; it's not how Git was designed to operate. The general overall design for Git is:

    • you get everything, then
    • you pick out the stuff you like.

    Unless there's some high cost to downloading unnecessary extra data, just let that work. If there is some such high cost, you will need to do work on the server side: create a branch name to identify the latest commit you'd like, then use a limited git fetch from the client. For instance:

    server$ git branch for-client a123456
    

    would create a new branch name for-client pointing to commit a123456, after which, on the client:

    client$ git fetch origin for-client
    

    would bring down commits up through and including a123456, after which you can refer to a123456 as origin/for-client.