Update All Repos Bash Script
Jul 13, 2024
Update Repositories Script
This script recursively finds all git repositories in a specified directory and pulls the latest changes for each one.
Prerequisites
- Bash shell
- Git installed
- Proper permissions to access and modify the repositories
Installation
-
Create the script: Save the following script to a file named
update_repos.sh:#!/bin/bash # Define the default root directory where your repos are located DEFAULT_ROOT_DIR="/home/cobra/Repos" # Use the provided argument as the root directory, or the default if none is provided ROOT_DIR= # Function to pull changes in a git repository # Export the function so it can be used by find -exec # Find all .git directories and pull changes in their parent directories -
Make the script executable:
-
Move the script to
/usr/local/bin: -
Verify the script is accessible: You can now run the script from anywhere by simply typing
update_reposin the terminal.
Usage
-
Open a terminal.
-
Run the script by typing:
- If no path is provided, it defaults to
/home/cobra/Repos.
- If no path is provided, it defaults to
The script will find all .git directories in the specified root directory and pull the latest changes for each repository. It will provide status updates during the process.
License
This project is licensed under the MIT License.