A robust Go command-line tool for archiving and restoring Git repositories, including both tracked and untracked files (respecting .gitignore).
Basically it does the same thing as the following shell script:
{ git ls-files --others --exclude-standard --cached && find .git -type f; } | \
sort -u | \
tar --exclude "$(basename $(pwd)).tar.gz" -czvf "$(basename $(pwd)).tar.gz" -T -tar -xzvf /path/to/repo.tar.gz -C /path/to/your/repoAdditional features to overcome the limitations of shell script:
- Support Git submodules
- Cross-platform native program
- Run command from any directory path
- Auto cleanup redundant files after restore
- Skip unchanged files during restore (by checking file modification time)
- Handle file permission issues during restore (files with permission 444 in .git/objects)
-
Clone the repository:
git clone https://github.com/likang/RepoArk.git cd RepoArk -
Build the program:
go build -o repoark
go install github.com/likang/RepoArk@latestrepoark /path/to/your/git/repository [output-file]- /path/to/your/git/repository: Path to the Git repository you want to archive.
- [output-file]: Optional. The name of the output archive file. If not provided, a unique name will be generated.
repoark restore /path/to/your/archive.tar.gz /path/to/your/git/repository - /path/to/your/archive.tar.gz: Path to the archive file you want to restore.
- /path/to/your/git/repository: Path to the directory where you want to restore the repository.
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Submit a pull request
MIT