有没有办法在我们的遥控器上备份,存档或以某种方式存储一些陈旧的分支?我们已经以某种方式在一个项目中累积了一个页面,这个项目已经让人们随着时间的推移来来往往,他们的分支大多只是在路上。我想删除&修剪它们但是如果我以某种方式备份它们会更喜欢它们。
思想?
答案 0 :(得分:1)
为此,我已经创建并运行了此自动化脚本,因为我不想将它们转换为过时的标签。
该脚本为每个分支差异生成补丁文件。您可以将它们存档在您的首选位置。
# Fetch the remote repos
git fetch
# List no-merged remote branches
BRANCHES=`git branch -r --no-merged | awk '{print($1)}'`
# List time-sorted branches with their time, id and author
for BRANCH in $BRANCHES;
do echo -e `git show --format="%ci %h %an" $BRANCH | head -n 1` \\t$BRANCH;
done | sort -r > targets
# Manually select the target lines
vim targets
# List branch names from it
BRANCHES=`cut -f 2 < targets`
# Dump the diffs of the branches
for BRANCH in $BRANCHES;
do git diff --no-prefix -U10 HEAD...$BRANCH > ${BRANCH//\//+}.patch;
done
# Delete the branches on the remote repo
REMOTE=origin
for BRANCH in $BRANCHES;
do BRANCH_IN_REMOTE=$(echo $BRANCH | sed "s/$REMOTE\///g");
echo "Deleting $BRANCH_IN_REMOTE";
git push $REMOTE --delete $BRANCH_IN_REMOTE;
done