Update README.md

This commit is contained in:
Ahmad-Samir 2024-06-27 04:35:03 +03:00 committed by GitHub
parent 10c80bb983
commit 372828b7b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 42 deletions

View File

@ -11,51 +11,11 @@ This Repo contains general standard modules for all projects.
- Then do the following:
> Each script will create a ceparate dir for each branch but outside `complete-odex25-standard-modules-repo`
- Inside the dir `complete-odex25-standard-modules-repo` , create a file named `checkout_branches.sh` and writes the script content into it:
```sh
#!/bin/bash
# List all branches that start with "dev" and check out each branch into a separate directory
for branch in $(git branch -r | grep "origin/dev" | sed "s|origin/||"); do
# Create a new directory for each branch
mkdir "../${branch}"
# Check out the branch into the newly created directory
git worktree add "../${branch}" $branch
done
# List all branches that start with "preprod" and check out each branch into a separate directory
for branch in $(git branch -r | grep "origin/preprod" | sed "s|origin/||"); do
# Create a new directory for each branch
mkdir "../${branch}"
# Check out the branch into the newly created directory
git worktree add "../${branch}" $branch
done
# List all branches that start with "master" and check out each branch into a separate directory
for branch in $(git branch -r | grep 'origin/master' | grep -vE 'origin/(HEAD|master$)' | sed 's|origin/||'); do
# Create a new directory for each branch
mkdir "../${branch}"
# Check out the branch into the newly created directory
git worktree add "../${branch}" $branch
done
```
- Run the script by:
```sh
$./checkout_branches.sh
```
- Run the script : `checkout_branches_full_names.sh`
- Output will be like: `master_odex25_hr` - `preprod_odex25_hr` - `dev_odex25_hr` - ...
> If you want to `Extract the directory name without 'dev_' prefix`
> ```sh
> for branch in $(git branch -r | grep 'origin/dev' | sed 's|origin/||'); do
> # Extract the directory name without 'dev_' prefix
> dir_name=$(echo $branch | sed 's|^dev_||')
> mkdir "../${dir_name}"
> git worktree add "../${dir_name}" $branch
> done
> ```
> If you want to `Extract the directory name without 'dev_' prefix`, use the script : `checkout_dev_branches_Extracted_names.sh`
> - Output will be like: `odex25_hr` - ...
----