Skip to content

Instantly share code, notes, and snippets.

@drofmij
Last active February 20, 2026 14:59
Show Gist options
  • Select an option

  • Save drofmij/b87a0cf7171c6c35bf4cbdf3782e987e to your computer and use it in GitHub Desktop.

Select an option

Save drofmij/b87a0cf7171c6c35bf4cbdf3782e987e to your computer and use it in GitHub Desktop.
GIT Cheat Sheet for some harder things.

clone 1 branch just the newest version of files

git --single-branch --branch=${BRANCHNAME} --depth 1 ssh://git@${DOMAIN}/${DIR}/${REPO}.git clone

delete old branches THAT WERE PREVIOUSLY MERGED ONLY

git branch --merged | grep -v "\*\|default"|xargs -n 1 git branch -d

resurrect deleted branch

git checkout -b ${BRANCH} ${SHA OF REVISION TO RESSURRECT}

FIX LINE BREAKS

find . \
    -path '**.git' -prune \
    -or -path '**/node_modules' -prune \
    -or -name '*jar' -prune \
    -or -name '*png' -prune \
    -or -name '*class' -prune \
    -or -name '*gif' -prune \
    -or -name '*jpg' -prune \
    -or -name '*war' -prune \
    -or -name '*' \
    -print0 |xargs -0 dos2unix
git add --renormalize .
git commit -m "line breaks"
git push

CLONE REPO BUT IGNORE LARGE FILES

git clone --filter=blob:limit=20m --progress --branch ${BRANCH} -v "https://${DOMAIN}/${DIR}/${REPO}.git"

useful links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment