Do a “git export” (like “svn export”)?

后端 未结 30 3447
暖寄归人
暖寄归人 2020-11-21 22:33

I\'ve been wondering whether there is a good \"git export\" solution that creates a copy of a tree without the .git repository directory. There are at least thr

30条回答
  •  南旧
    南旧 (楼主)
    2020-11-21 22:41

    For GitHub users, the git archive --remote method won't work directly, as the export URL is ephemeral. You must ask GitHub for the URL, then download that URL. curl makes that easy:

    curl -L https://api.github.com/repos/VENDOR/PROJECT/tarball | tar xzf -
    

    This will give you the exported code in a local directory. Example:

    $ curl -L https://api.github.com/repos/jpic/bashworks/tarball | tar xzf -
    $ ls jpic-bashworks-34f4441/
    break  conf  docs  hack  LICENSE  mlog  module  mpd  mtests  os  README.rst  remote  todo  vcs  vps  wepcrack
    

    Edit
    If you want the code put into a specific, existing directory (rather than the random one from github):

    curl -L https://api.github.com/repos/VENDOR/PROJECT/tarball | \
    tar xzC /path/you/want --strip 1
    

提交回复
热议问题