Exact `svn export` equivalent command for git?

前端 未结 8 844
花落未央
花落未央 2021-02-06 04:53

There is no exact svn export equivalent command for git? Really?

Beware: this is not a duplicate question. That is, I already know and have

8条回答
  •  不知归路
    2021-02-06 05:19

    This is a rather old questions, nevertheless I didn't find an "obvious solution" in my opinion. After some research of the git documentation I found:

    git archive --format=tar --remote ... | tar xf -
    

    This will receive the contents even from a remote repository and write a tar archive to stdout. The tar command then will extract the contents and create it in your current directory.

    If you like to do that from a local repository (which was explicitly not the desired request in the question), then

    git archive --format=tar ... | ( cd /your/path && tar xf - )
    

    will do the trick for you. The first approach works on Windows command prompt as well, if you have tar installed. The latter most probably does not and may overwrite your directory.

提交回复
热议问题