For some reason, remote git repository was broken and there aren´t backups, but there are a lot of local repositories in developer machines. Every developer machine has a few branches that they use, but anyone has all branches checkout in local repository.
Is recommended use a local repository to rebuild remote repository?
We tried to push all local branches in remotes repository, but there were several branches that no one has in local. For these branches we build a shell script to checkout and push, but I am not sure if it is the correct way.
This was the created shell script:
#!/bin/bash
clear
echo "*****************************************"
echo "Disaster Recovery. "
echo "Script for massive Git checkout and push."
echo "*****************************************"
for i in $(git branch -r)
do
find="origin/";
replace="";
branch=${i//$find/$replace}
echo "Init checkout" $branch
exec git branch -d $branch | git checkout -b $branch --track origin/$branch
echo "End checkout" $branch
done;
echo "Init push -all"
echo exec git push --all
echo "End push -all"
All branches was recovery but some was outdated for long time difference. In this case, the newest local developer branch was searched and pushed. Some branches remained outdated, because no one has recent local branch.
There are others way to rebuild all remote git repository without git server backup? Thanks for your time, community