Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exact `svn export` equivalent command for git?

There is no exact svn export equivalent command for git? Really?

Beware: this is not a duplicate question. That is, I already know and have tested these commands:

  • git clone --depth 1 <- Still downloads the .git folder.
  • git checkout-init <- Doesn't work for a remote repo, it works with a working copy (so you need to clone first).
  • git archive <- This would be the perfect solution, because it has a --remote argument, but it only has 2 possible formats: tar or zip, so I would need to untar/unzip after downloading, and for that I need a pipe (|), but I'm on windows!! (not *n?x)
  • git clone --bare <- I still don't know what the heck this is, but it's not what I need.

Please enlighten me is there a real svn export replacement in git?

like image 293
knocte Avatar asked Jun 30 '11 17:06

knocte


People also ask

What is SVN export command?

export command is used to download a project repository in to the local computer or machine on to the specified folder or directory. The difference between checkout and export is that, export will extract all the files from a revision and does not act as working copy.

What is git SVN command?

What is Git-SVN? The git-svn tool is an interface between a local Git repository and a remote SVN repository. Git-svn lets developers write code and create commits locally with Git, then push them up to a central SVN repository with svn commit-style behavior.

How do I export a git repository?

Exporting a Repository Step 1: Go to your git bash. and then to the repo you want to extract or export. Here, we are going to export this repo named 'Ada August-a Challenge' and it's main branch. Step 2: Now export it to your preferred format and location, here we will export it to the same location in .

What is git SVN fetch?

This retrieves all the changes from the SVN repository and applies them on top of your local commits in your current branch. You can also use git svn fetch to retrieve the changes from the SVN repository but without applying them to your local branch.


3 Answers

This is a rather old questions, nevertheless I didn't find an "obvious solution" in my opinion. After some research of the git documentation I found:

git archive --format=tar --remote ... | tar xf -

This will receive the contents even from a remote repository and write a tar archive to stdout. The tar command then will extract the contents and create it in your current directory.

If you like to do that from a local repository (which was explicitly not the desired request in the question), then

git archive --format=tar ... | ( cd /your/path && tar xf - )

will do the trick for you. The first approach works on Windows command prompt as well, if you have tar installed. The latter most probably does not and may overwrite your directory.

like image 117
toaster Avatar answered Sep 22 '22 13:09

toaster


Just get rid of the repository within the working copy.

git clone remote
rm -Rf .git

(On Windows, it's rd /s /q. Thanks for the hint by @Bruno.)

like image 31
KingCrunch Avatar answered Sep 18 '22 13:09

KingCrunch


From How do I do a quick clone without history revisions?:

git clone --depth 1 your_repo_url

Then, from the rmdir documentation:

rd /s /q .git
like image 42
Bruno Avatar answered Sep 21 '22 13:09

Bruno