Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: How to Archive from remote repository directly?

Tags:

git

I usually use the command below inside my project.git to get an archive in the specified destinations:

git archive master | tar -x -C /home/kave/site/ 

I wonder if its possible to archive directly from a remote repository instead into a destination directory?

I tried something like this, without any joy:

git archive master https://[email protected]/myoproject.git | tar -x -C /home/kave/site/ 

Any suggestions? Thanks

like image 453
Houman Avatar asked Dec 06 '12 18:12

Houman


People also ask

How do I archive a git repository?

To archive a repository, go to your Repository Settings Page and click Archive this repository. Before archiving your repository, make sure you've changed its settings and consider closing all open issues and pull requests.

How do I pull files from a remote git repository?

The git pull command is used to fetch and download content from a remote repository and immediately update the local repository to match that content. Merging remote upstream changes into your local repository is a common task in Git-based collaboration work flows.

What is the git command to create the archive files?

The git archive command is a Git command line utility that will create an archive file from specified Git Refs like, commits, branches, or trees.

Can you archive branches git?

Well, there is no such option like archiving branches in git. But we can create a tag with a prefix like “archive”. In other words, we move entry about the feature from branch list to tags list. To restore the branch, checkout it by the tag.


1 Answers

From git help archive:

   --remote=<repo>        Instead of making a tar archive from the local repository, retrieve a tar archive from a remote repository. 

Command should end up like:

$ git archive --remote=https://[email protected]/myoproject.git master 

But, if you would just extract the repo, you can make a shallow clone using --depth parameter of git clone:

   --depth <depth>        Create a shallow clone with a history truncated to the specified number of revisions. A shallow repository has a number of limitations (you cannot clone or fetch from it, nor push from nor into it), but is adequate if you are only interested in the recent history of a large project with a long history, and would want to send in fixes as patches. 

So you have something like this:

$ git clone --depth=1 https://[email protected]/myoproject.git 
like image 122
mgarciaisaia Avatar answered Oct 04 '22 17:10

mgarciaisaia