Created
August 28, 2024 19:15
-
-
Save narskidan/de63964688fbca5bd1b4c28fb6801a35 to your computer and use it in GitHub Desktop.
Backup my git repos before switching to new laptop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cd ~/Documents/Code | |
for directory in *; do | |
if ! [ -d "$directory" ]; then continue; fi | |
cd "$directory" | |
# Check if this directory is a Git repository | |
if git rev-parse --is-inside-work-tree; then | |
git pull | |
git add . | |
git commit -m 'Backing up repos (switching to new laptop)' | |
git push --force | |
fi | |
## Change back to `~/Documents/Code`` directory | |
cd .. | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment