git copy particular version of repository

后端 未结 2 1145
日久生厌
日久生厌 2021-01-03 14:50

I\'m new to git so forgive me if this is a dumb question. I have a git repository and I need to copy a particular revision of the repository to its own separate directory. T

相关标签:
2条回答
  • 2021-01-03 15:38
     git archive master >specificversion.tar
    

    replace master by a commit identifier

    If you want to immediately 'check it out', consider

     git archive master | (cd /tmp/exportlocation && tar x)
    

    git archive (as usual) comes with a load of other useful options

    0 讨论(0)
  • 2021-01-03 15:43

    Update

    It's better to use the archive option mentioned by Sehe


    What I would do is just checkout that particular version:

    git checkout <commit-sha1>
    

    And then just copy all the contents except for the .git dir

    rcopy --exclude=.git . ~/some-folder/
    

    And then you could do

    git checkout master
    

    to reset the repository to the master branch again.

    0 讨论(0)
提交回复
热议问题