The Living Thing / Notebooks : Stupid git tricks

Decent GUIs

subtrees

creatin’:

git fetch remote branch
git subtree add --prefix=subdir remote branch --squash

updatin’:

git fetch remote branch
git subtree pull --prefix=subdir remote branch --squash
git subtree push --prefix=subdir remote branch --squash

importing some files across a branch

git check my_branch -- my_file/

Garbage collecting

In brief, this will purge a lot of stuff from a constipated repo in emergencies:

git reflog expire --expire=now --all
git gc --prune=now

In depth

Cleaning out all big files even from project history

bfg does that:

java -jar bfg.jar --strip-blobs-bigger-than 100M some-big-repo.git

Making it work with a broken-permissions FS

e.g. you are editing a git repo on NTFS via Linux and things are silly.

git config core.filemode false

Splitting off a sub-project

Use subtree split to prise out one chunk. It has a few wrinkles but is fast and easy.

pushd superproject
git subtree split -P project_subdir -b project_branch
popd
mkdir project
pushd project
git init
git pull ../superproject project_branch