Retrieve specific commit from a remote Git repository

后端 未结 10 1794
谎友^
谎友^ 2020-11-22 06:32

Is there any way to retrieve only one specific commit from a remote Git repo without cloning it on my PC? The structure of remote repo is absolutely same as that of mine and

10条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 06:43

    If the requested commit is in the pull requests of the remote repo, you can get it by its ID:

    # Add the remote repo path, let's call it 'upstream':
    git remote add upstream https://github.com/repo/project.git
    
    # checkout the pull ID, for example ID '60':
    git fetch upstream pull/60/head && git checkout FETCH_HEAD
    

提交回复
热议问题