-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgit-declone
More file actions
executable file
·31 lines (25 loc) · 984 Bytes
/
git-declone
File metadata and controls
executable file
·31 lines (25 loc) · 984 Bytes
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
26
27
28
29
30
31
#!/bin/bash
#
# Old `git clone` of repositories lying about with or without changes, take
# up space. What if we can get rid of these clones without losing our work?
#
# This is a git 'unclone' in a sense that it also tries to preserve unpushed
# revisions. So, it turns the local branches into patches, so that the clone
# can be safely deleted. This does not take reflogs into account.
#
output=$1
if [[ "$output" == "" ]] ; then
exit -1
fi
git branch -v > ${output}/local-branch-state
git branch -rv > ${output}/remote-branch-state
git remote -v > ${output}/remote-state
for branch in $(git show-ref | grep ' refs/heads/' | cut -c53-) ; do
mkdir -p ${output}/${branch}
git format-patch $(for i in $(git show-ref | grep ' refs/remotes/' | cut -c41- | grep -v HEAD); do echo $i..${branch}; done) -o ${output}/heads/${branch}
rmdir ${output}/${branch} 2>/dev/null
if [[ -e ${output}/${branch} ]] ; then
echo ${branch}
ls -l ${output}/${branch}
fi
done