(1) Use git archive (for backup one branch) like the below command (Suppose you are inside Git local repository):
git archive master --format=zip --output=java_exmamples.zip
you will see file java_exmamples.zip
(in the same folder) is the backup of master branch.
(2) Use git bundle (for backup all branches)
A real example:
git clone --mirror https://github.com/donhuvy/java_examples.git
cd java_examples.git/
git bundle create repo.bundle --all
repo.bundle
is the file what you need (full back up) in the same directory.
How to restore from file repo.bundle
:
git clone repo.bundle
Reference
https://git-scm.com/docs/git-archive
https://git-scm.com/docs/git-bundle
http://rypress.com/tutorials/git/tips-and-tricks#bundle-the-repository