-
Notifications
You must be signed in to change notification settings - Fork 12
/
Update-GitSubtree.ps1
25 lines (19 loc) · 965 Bytes
/
Update-GitSubtree.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Reference https://www.sourcefield.nl/post/git-subtree-survival-tips/
param(
$Ref = "main", # branch or tag; defaults to 'master' if parameter 1 not present
$Remote = "some-remote", # just a name to identify the remote
$Repo = "https://github.com/actions/virtual-environments.git", # replace this with your repository URL
$Folder = ".github-actions" # where to mount the subtree
)
git remote add $REMOTE --no-tags $REPO
if(Test-Path $Folder) # update the existing subtree
{
git subtree pull $REMOTE $REF --prefix=$FOLDER --squash -m "Merging '$REF' into '$FOLDER'"
}
else # add the subtree
{
git subtree add $REMOTE $REF --prefix=$FOLDER --squash -m "Merging '$REF' into '$FOLDER'"
}
git remote remove $REMOTE
# git subtree add --prefix .github-actions https://github.com/actions/virtual-environments.git master --squash
# git subtree pull --prefix .github-actions https://github.com/actions/virtual-environments.git master --squash