File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -106,6 +106,55 @@ git pull
106
106
cd ..
107
107
```
108
108
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
+
109
158
## License
110
159
111
160
- MIT License
You can’t perform that action at this time.
0 commit comments