Retrieve specific commit from a remote Git repository

后端 未结 10 1799
谎友^
谎友^ 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:39

    Finally i found a way to clone specific commit using git cherry-pick. Assuming you don't have any repository in local and you are pulling specific commit from remote,

    1) create empty repository in local and git init

    2) git remote add origin "url-of-repository"

    3) git fetch origin [this will not move your files to your local workspace unless you merge]

    4) git cherry-pick "Enter-long-commit-hash-that-you-need"

    Done.This way, you will only have the files from that specific commit in your local.

    Enter-long-commit-hash:

    You can get this using -> git log --pretty=oneline

提交回复
热议问题