i'm working with jenkins/git and i want to clean my directory (/var/www/branches/) from old git branches this branches are represented as folders in a different directory ( a part from my git repository), what i do is that i retrieve current working branches put them in a file using the command :
listBranchRemote=$(git --git-dir=$gitDirectory/.git branch -qr |cut -d'/' -f 2,3 | tee -a branch.txt
)
the branch.txt
represents the only folders that should be kept in /var/www/branches/ directory. How to delete folders not in my file that i created.