Home > Software engineering >  alternative to git archive for exporting
alternative to git archive for exporting

Time:11-09

I have been using git for ages but there are some things that just don't click for me.

As part of my normal build system, I need to export a specific tag into a temporary source directory and the only way I've found to do this is by using git archive.

Specifically:

/Applications/Xcode.app/Contents/Developer/usr/bin/git archive #{internal_version} --format=zip > #{$temp_source_code_path}/code.zip

This is stupid as I first need to zip the entire thing and then unzip it before building it.

The actual git repository is local and the command is run from it.

Is there a better (faster) way of doing this?

Best regards,

Frank

CodePudding user response:

You can clone a local repository just like you would a remote one:

git clone /path/to/your/repo /path/to/build/dir

Then, whenever you need to build, you can run

cd /path/to/build/dir
git pull
# Run build script

This has the added benefit that it'll only copy over changes, rather than archiving the entire repository.

That being said, rsync might be a more appropriate tool

CodePudding user response:

Here are two possible ways :

CodePudding user response:

If you want to export files from git without creating an intermediate archive, you can pipe the data through tar directly:

git archive master | tar xC /some/path

If you want to be able to perform git operations in the directory where the files are exported, consider using git clone or git worktree instead.

  •  Tags:  
  • git
  • Related