Steven Lu
Steven Lu

Reputation: 2180

How do I clone a git repository to a new project?

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.

Upvotes: 4

Views: 3635

Answers (2)

VonC
VonC

Reputation: 1323165

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://[email protected]/username/reponame.git --format=tar --output="file.tar" master

Upvotes: 3

cnd
cnd

Reputation: 33714

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

Upvotes: -1

Related Questions