git checkout master
git archive stage | tar -czf archive.tar.gz htdocs
# archives master because it's checked out.
How can I archives the stage branch, regardless of the current I'm on?
There will be a archive option for each branch, beside the delete option for the branch. A user selecting that will get prompted to be sure they want to archive the branch. Archiving the branch will result in the branch only showing on a new Archived tab on the branches page.
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.
If you want to delete a branch completely, you can just delete it in all your repositories (typically local and remote). git will then clean it up next time it garbage collects.
There is no "git export" command, so instead you use the "git archive" command. By default, "git archive" produces its output in a tar format, so all you have to do is pipe that output into gzip or bzip2 or other.
git archive creates a tar archive so you don't need to pipe its output tar, indeed it's not doing what you expect. You are creating an tar archive of the stage branch and piping it to a normal tar command which doesn't use its standard input but just creates its own archive of htdocs
in the working tree, independently of git.
Try:
git archive stage >stage.tar
or, for a compressed archive:
git archive stage | gzip >stage.tar.gz
To just archive the htdocs subfolder you can do:
git archive stage:htdocs | gzip >stage-htdocs.tar.gz
or, to include the folder name in the archive:
git archive --prefix=htdocs/ stage:htdocs | gzip >stage-htdocs.tar.gz
or more simply:
git archive stage htdocs | gzip >stage-htdocs.tar.gz
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With