update: git backup and restore documentation improved.

This commit is contained in:
jj 2025-05-21 12:55:43 +02:00
parent bc16701f53
commit f24a7033d1

View file

@ -91,20 +91,28 @@ Add executable flag on Windows:
git update-index --chmod=+x git_mirror.sh
```
Check the remote branch of a cloned repository and change it:
Backup a repository from a source with all branches and tags.
```bash
# fresh clone
git clone --mirror <source-repo-url>
# existing local clone update
git fetch --all --tags --prune
#Optional: zip it
tar czf repo-backup.git.tar.gz repo.git
```
Restore a repository to a new destination with all branches and tags.
```bash
cd repo.git
git remote -v
git remote set-url origin <new-repo-url>
git remote -v
git remote set-url origin xwr@vs-ssh.visualstudio.com:v3/xwr/jambor.pro/app-docker-compose
git remote -v
for branch in $(git branch -r | grep -v '\->'); do
git checkout ${branch#origin/}
git push -u origin HEAD
git push --tags origin
done
git push --mirror
```
Renaming branches:
@ -122,3 +130,5 @@ git branch -m main wikiMaster
# Push
git push origin HEAD
```