Skip to content

Commit fa4dec7

Browse files
authored
Update README.md
1 parent d62f591 commit fa4dec7

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,55 @@ git pull
106106
cd ..
107107
```
108108

109+
## Bash (Linux, Unix)
110+
111+
- `fetchAll.sh`
112+
113+
```bash
114+
#!/bin/bash
115+
116+
# Save the current working directory
117+
WORKDIR=$(pwd)
118+
119+
# Set Git repository name and URL
120+
GIT_NAME="QPing"
121+
GIT_REPO="https://github.com/JayTwoLab/QPing.git"
122+
123+
# Remove the existing directory if it exists
124+
if [ -d "$GIT_NAME" ]; then
125+
rm -rf "$GIT_NAME"
126+
fi
127+
128+
# Clone the Git repository
129+
git clone "$GIT_REPO"
130+
cd "$GIT_NAME" || exit 1
131+
132+
# Fetch all remote branches
133+
git fetch --all
134+
135+
# Get list of remote branches excluding HEAD and origin/master
136+
branches=$(git branch -r | grep -v "HEAD" | grep -v "origin/master")
137+
138+
# For each branch, check it out and pull the latest changes
139+
while read -r full_branch; do
140+
full_branch=$(echo "$full_branch" | xargs) # Trim whitespace
141+
branch_name=${full_branch#origin/} # Remove 'origin/' prefix
142+
143+
echo ""
144+
echo "[Checkout and pull] $full_branch$branch_name"
145+
146+
git checkout -B "$branch_name" "$full_branch"
147+
git pull origin "$branch_name"
148+
done <<< "$branches"
149+
150+
# Switch back to master branch and pull
151+
git checkout master
152+
git pull
153+
154+
# Return to the original working directory
155+
cd "$WORKDIR" || exit 1
156+
```
157+
109158
## License
110159

111160
- MIT License

0 commit comments

Comments
 (0)