4

For example, I want to use some framework that's located on Github. Is there a way to clone a repository without the .git structure? That way I can add new a remote url and push to my own repository appropriately?

Edit

The purpose of this is so that I can take a framework off from Github and put it into my own brand new repository without importing any git data from the framework's repository (like git logs). I know you can clone and remove the appropriate data or you could just download a tarball using Github's tool, but I'm just wondering if there's any easier way to do it such as like a git clone, preferably a single command.

Steven Lu
  • 2,150
  • 1
  • 24
  • 33
  • According your comment on my removed question I don't understand your question. Why don't you want .git structure? Why don't you want to use fork? Provide some more details. – cnd Aug 22 '12 at 05:00
  • I want to import the repository as my own "clean" repository. Kind of like starting off from scratch with a framework that you use. Obviously from this, you don't want to import the git logs that it contains. That way, your starting off with a brand new git repository with the framework you want to use. I'm just asking if there's an easier way to do a `git clone` rather than doing it myself with rm's. – Steven Lu Aug 22 '12 at 05:04

2 Answers2

3

If you want just the repo latest content, without any git information, then the tarball is the best solution, and can be done with a single command line:

curl -L https://github.com/username/reponame/tarball/master | tar zx

or

wget --no-check-certificate https://github.com/username/reponame/tarball/master -O - | tar xz

Even on Windows, you can do it, with the unix-like commands from GoW (Gnu On Windows).

That would allow you then to add that new directory as one of your own.

Note: a submodule would be preferable, but isn't what you specifically asked.


The OP Steven Lu adds in the comments:

I guess this works for Github, but what would you do if the repo wasn't hosted by Github?

For any other repo, you can use the command git archive --remote, as illustrated in "git archive command with bitbucket":

For instance:

git archive --remote=ssh://git@bitbucket.org/username/reponame.git --format=tar --output="file.tar" master
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I guess this works for Github, but what would you do if the repo wasn't hosted by Github? – Steven Lu Aug 22 '12 at 14:22
  • 1
    @StevenLu `git archive --remote`: see http://stackoverflow.com/questions/12071070/git-archive-command-with-bitbucket/12073669#12073669 – VonC Aug 22 '12 at 14:25
  • @StevenLu I have included the alternative solution in the answer for more visibility. – VonC Aug 23 '12 at 07:35
-1

How do I do a quick clone without history revisions?

git clone --depth 1 your_repo_url

source : https://git.wiki.kernel.org/index.php/GitFaq#How_do_I_do_a_quick_clone_without_history_revisions.3F

cnd
  • 32,616
  • 62
  • 183
  • 313
  • I can't be sure but I think there is no git way without .git @VonC pointed that you can download archive in github way. – cnd Aug 22 '12 at 09:35