##find ignored files in directory
git clean -n -X
##... delete them
git clean -X
##changes made in staged (in-index-but-not-commited) files
git diff --staged
#checkout multiple git repos from github
repos=(repo1 repo2 repo3)
for i in "${repos[@]}"
do
if [ -d "$i" ]
then
echo "Directory $i exists. Not fetching."
else
echo "Fetching $i ..."
git clone git@github.com:<yourusername>
/$i.git
echo "Fetching $i ... Done"
fi
done
#save work before rebasing from master
You want to pull from master and replay your changes on top of that. But you have unstaged changes in working directory. Do the following :
git stash
git pull --rebase
git stash pop
#remove unwanted folders from git repo
#!/bin/sh
#This script will help you remove unwanted folders in your git repository along with the associated history
SRC='src-git-folder'
TARGET='target-git-folder'
#all the paths you want to retain in the repo
INCLUDE_PATHS='^(patha|pathb)'
mkdir $TARGET
cp -R $SRC/.git ./$TARGET/.git
cd $TARGET
git reset --hard HEAD
echo "pulling all remote branches.."
git branch -r | cut -d "/" -f2,3 | grep -v HEAD | xargs -n 1 git checkout
git remote rm origin
git checkout master
echo "rewriting history.."
git filter-branch --index-filter "git ls-files | grep -E -v '$INCLUDE_PATHS' | tr '\n' ' ' | xargs git rm --cached --ignore-unmatch" --prune-empty --tag-name-filter cat -- --all
echo "deleting unused backup references.."
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
git reflog expire --expire=now --all
git reset --hard
echo "garbage collecting unwanted objects.."
git gc --aggressive --prune=now
echo "done!"