How do I download a specific git commit from a repository?

前端 未结 8 2205
北海茫月
北海茫月 2020-12-15 06:10

I don\'t have a local code copy/etc, I just want to download a single specific git commit so I can view it. I have the url for the git repository:

git://git.kernel.o

相关标签:
8条回答
  • 2020-12-15 06:35

    I know this works when you have a clone of the repo (or a similar repo)..

    git fetch git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6.git
    git cherry-pick ee9c5cfad29c8a13199962614b9b16f1c4137ac9
    

    Fetch downloads the remote refs (but not the whole repo, I don't think) so that you can reference them with the other commands. Then you cherry-pick that one commit, and it attempts to apply the diff to your local tree.

    I haven't tried it without a git repo locally, but I have tried it on repos that are not forks of eachother. you may get merge conflicts, but you can clean those up manually.

    0 讨论(0)
  • 2020-12-15 06:40

    There is a way to do this:

    git show ee9c5cfad29c8a13199962614b9b16f1c4137ac9 > myCommittedCode.txt
    
    0 讨论(0)
提交回复
热议问题