| description | Text. How to do nonobvious (to me) stuff with git | 
| last change | Fri, 9 Jun 2023 20:27:25 +0000 (16:27 -0400) | 
| URL | https://git@git.xandkar.net/clone/git-cheat-sheet.git | 
How to do stuff with git
$ git clone old new
$ cd new
$ git clean -dfx
$ git gc --aggressive --prune=now
$ git remote rm origin
$ git filter-branch \
    --prune-empty \
    --index-filter '
        git ls-tree -r --name-only HEAD \
        | grep -v file_i_want_to_keep_1 \
        | grep -v file_i_want_to_keep_.. \
        | grep -v file_i_want_to_keep_n \
        | xargs git rm --cached -r --ignore-unmatch
    ' \
    HEAD
$ git gc --aggressive --prune=now$ git log --pretty=format: --name-status \
    | awk '$0 != "" {print $2}' \
    | sort -u > /tmp/tree.old
$ git ls-tree -r --name-only HEAD > /tmp/tree.new
$ git filter-branch \
    --prune-empty \
    --index-filter '
        grep -Fvxf /tmp/tree.new /tmp/tree.old \
        | xargs git rm --cached -r --ignore-unmatch
    ' \
    HEADgit checkout --orphan $TEMP_BRANCH
git rm -rf .
git commit --allow-empty -m $INIT_COMMIT_MSG
git rebase --onto $TEMP_BRANCH --root $MAIN_BRANCH
git branch -d $TEMP_BRANCHFrom docs:
git rebase -i <commit>^, where <commit> is the commit you want to split.git reset HEAD^. The effect is that the HEAD is rewound by one, and the index follows suit. However, the working tree stays the same.git add)git rebase --continue.| 2 years ago | master | shortlog | log | tree |