git export from github remote repository

前端 未结 10 1273
北恋
北恋 2020-12-07 13:50

I\'d like to export from github remote repository, not cloning it. Similar to svn export, I do not want to get .git folder with it. I can work around it by cloning and remov

10条回答
  •  -上瘾入骨i
    2020-12-07 14:44

    I ran into this same problem before, and AFAICT, it only seems to work with Bitbucket, e.g.

    ysim:~/repos$ git archive --format=tar --prefix=alembic/ --remote=ssh://git@bitbucket.org/zzzeek/alembic.git master | tar -xf -
    ysim:~/repos$ ls
    alembic
    

    But I found a workaround for GitHub using wget - so in the new GitHub interface, you'll find a button that says "Download ZIP" on the bottom of the right sidebar; right-click on it and copy the link address.

    Download ZIP

    Next, in the command line (I got the idea from here):

    wget -qO- -O tmp.zip  && unzip tmp.zip && rm tmp.zip
    

    That will unzip it to a directory called something like repo-master/.

    If you want, you can also alias this in your .gitconfig so you don't have to remember/type all of that out, e.g.

    export = "! f() { wget -qO- -O tmp.zip \"$1\" && unzip tmp.zip && rm tmp.zip; }; f"
    

    So you can just do something like this in the shell:

    ysim:~/repos$ git export https://github.com/ysim/verbinski/archive/master.zip
    ysim:~/repos$ ls
    verbinski-master
    

提交回复
热议问题