This commit is contained in:
gitadminexpsa 2024-06-27 03:05:23 +03:00
commit 9dbd2485cd
1 changed files with 58 additions and 0 deletions

View File

@ -2,6 +2,64 @@
This Repo contains general standard modules for all projects.
----
## If you want to install each branch in separate directory, use the below:
- First: clone the full repo, say you named it `complete-odex25-standard-modules-repo`
- Second: `$cd complete-odex25-standard-modules-repo`
- 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
```
- 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
> ```
> - Output will be like: `odex25_hr` - ...
----
### Branches:
- dev_odex-event
- dev_odex25_accounting