Skip to content

Commit db2ba68

Browse files
committed
inital commit
1 parent 3d44907 commit db2ba68

File tree

2 files changed

+124
-1
lines changed

2 files changed

+124
-1
lines changed

README.md

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,69 @@
11
# fetch_all_git_branch
2-
Windows Cmd file to fetch all branches in a git branch.
2+
3+
- Windows Cmd file to fetch all branches in a git branch.
4+
5+
## Cmd file
6+
7+
- `fetch.cmd`
8+
9+
```cmd
10+
:: fetch.cmd
11+
::
12+
:: This script deletes and re-clones specific Git repositories,
13+
:: and runs git commands (like git pull) inside each one after cloning.
14+
15+
@echo off
16+
17+
:: Please set the values below.
18+
set GIT_REPO_NAME=QPing
19+
set GIT_REPO=https://github.com/JayTwoLab/QPing.git
20+
21+
:: Remove old directory
22+
if exist %GIT_REPO_NAME% (
23+
rmdir /s /q %GIT_REPO_NAME%
24+
)
25+
git clone %GIT_REPO%
26+
cd %GIT_REPO_NAME%
27+
28+
setlocal enabledelayedexpansion
29+
30+
:: Fetch all remote branches
31+
git fetch --all
32+
33+
:: Exclude origin/HEAD and origin/master from the list
34+
for /f "tokens=*" %%b in ('git branch -r ^| findstr /V "HEAD" ^| findstr /V "origin/master"') do (
35+
:: Get the full remote branch name (e.g., origin/feature-x)
36+
set "full_branch=%%b"
37+
38+
:: Remove 'origin/' prefix
39+
set "branch_name=%%b"
40+
set "branch_name=!branch_name:origin/=!"
41+
42+
echo.
43+
echo [Checkout and pull] %%b → !branch_name!
44+
45+
:: Checkout to local branch tracking the remote branch
46+
git checkout -B !branch_name! %%b
47+
48+
:: Pull latest changes for the branch
49+
git pull origin !branch_name!
50+
)
51+
52+
endlocal
53+
54+
:: Checkout master branch
55+
git checkout master
56+
git pull
57+
git status
58+
59+
:: Move to parent directory
60+
cd
61+
cd ..
62+
cd
63+
```
64+
65+
## License
66+
67+
- MIT License
68+
- https://github.com/JayTwoLab/fetch_all_git_branch
69+

fetchAll.cmd

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
:: fetch.cmd
2+
::
3+
:: This script deletes and re-clones specific Git repositories,
4+
:: and runs git commands (like git pull) inside each one after cloning.
5+
6+
@echo off
7+
8+
:: Please set the values below.
9+
set GIT_REPO_NAME=QPing
10+
set GIT_REPO=https://github.com/JayTwoLab/QPing.git
11+
12+
:: Remove old directory
13+
if exist %GIT_REPO_NAME% (
14+
rmdir /s /q %GIT_REPO_NAME%
15+
)
16+
git clone %GIT_REPO%
17+
cd %GIT_REPO_NAME%
18+
19+
setlocal enabledelayedexpansion
20+
21+
:: Fetch all remote branches
22+
git fetch --all
23+
24+
:: Exclude origin/HEAD and origin/master from the list
25+
for /f "tokens=*" %%b in ('git branch -r ^| findstr /V "HEAD" ^| findstr /V "origin/master"') do (
26+
:: Get the full remote branch name (e.g., origin/feature-x)
27+
set "full_branch=%%b"
28+
29+
:: Remove 'origin/' prefix
30+
set "branch_name=%%b"
31+
set "branch_name=!branch_name:origin/=!"
32+
33+
echo.
34+
echo [Checkout and pull] %%b!branch_name!
35+
36+
:: Checkout to local branch tracking the remote branch
37+
git checkout -B !branch_name! %%b
38+
39+
:: Pull latest changes for the branch
40+
git pull origin !branch_name!
41+
)
42+
43+
endlocal
44+
45+
:: Checkout master branch
46+
git checkout master
47+
git pull
48+
git status
49+
50+
:: Move to parent directory
51+
cd
52+
cd ..
53+
cd
54+
55+
56+

0 commit comments

Comments
 (0)