Exact `svn export` equivalent command for git?

前端 未结 8 858
花落未央
花落未央 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:10

    Just get rid of the repository within the working copy.

    git clone remote
    rm -Rf .git
    

    (On Windows, it's rd /s /q. Thanks for the hint by @Bruno.)

    0 讨论(0)
  • 2021-02-06 05:11

    The question "how can I do a svn-style 'export' with git?" is like asking "How can I change the tires on my basketball?". You can't, but that's not the basketball's fault. Yes it is rubber and full of air, but the similarity ends there.

    You only need "export" with svn because it pollutes every single subdirectory with a .svn directory. Git doesn't do that, so you really don't need it. A clone IS an export, just with one directory at the root dir that all the repository business lives in.

    The easiest thing is to clone the repo and then just delete the .git directory from the top level of the repo. Do that, and it's not a repo anymore, it's just a stand-alone directory of files.

    Or, you know, ignore git all together and just use the files you cloned down. That works too.

    0 讨论(0)
  • 2021-02-06 05:18

    For your I still don't know what the heck this is: git clone --bare will clone the repository without a working copy. This is usually done on a central repository so as to minimise disk space usage.

    Bruno / King Crunch have the best answer. Although you could use git bash / cygwin to allow you to pipe if you need a one-liner.

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2021-02-06 05:21

    From How do I do a quick clone without history revisions?:

    git clone --depth 1 your_repo_url
    

    Then, from the rmdir documentation:

    rd /s /q .git
    
    0 讨论(0)
  • 2021-02-06 05:21

    From https://stackoverflow.com/a/160719/43597

    git checkout-index -a -f --prefix=/destination/path/
    
    0 讨论(0)
提交回复
热议问题