Do A "git Export" (like "svn Export")?
I've been wondering whether there is a good "git export" solution that creates a copy of a tree without the
.git repository directory. There are at least three methods I know of:
git clonefollowed by removing the
git checkout-indexalludes to this functionality but starts with "Just read the desired tree into the index..." which I'm not entirely sure how to do.
git-exportis a third-party script that essentially does a
git cloneinto a temporary location followed by
rsync --exclude='.git'into the final destination.
None of these solutions really strike me as being satisfactory. The closest one to
svn export might be option 1, because both require the target directory to be empty first. But option 2 seems even better, assuming I can figure out what it means to read a tree into the index.
Probably the simplest way to achieve this is with
git archive. If you really need just the expanded tree you can do something like this.
git archive master | tar -x -C /somewhere/else
Most of the time that I need to 'export' something from git, I want a compressed archive in any case so I do something like this.
git archive master | bzip2 >source-tree.tar.bz2
git archive --format zip --output /full/path/to/zipfile.zip master
git help archive for more details, it's quite flexible.
Be aware that even though the archive will not contain the .git directory, it will, however, contain other hidden git-specific files like .gitignore, .gitattributes, etc. If you don't want them in the archive, make sure you use the export-ignore attribute in a .gitattributes file and commit this before doing your archive. Read more...
Note: If you are interested in exporting the index, the command is
git checkout-index -a -f --prefix=/destination/path/
(See Greg's answer for more details)
- → Authenticate with a cookie using laravel 5.1 and jwt
- → Finding a specific GitLab tag from PHP
- → React: How to publish page on server using React-starter-kit
- → babel-loader, webpack, ES2015 modules: "Element type is invalid"
- → Create a function-attribute of a function, which is, in its turn, a method of an object literal
- → Model Validation in laravel 5.1 not working
- → GIT fatal: loose object
- → Laravel validation required rule not working
- → Axios array map callback
- → Where does this `webpack://` come from for `webpack-dev-middleware`?
- → error when trying to modify project in laravel forge
- → GitHub Pages and Jekyll content duplication and SEO issues
- → Use Laravel repositories with Datatables