- clean up branches that have been merged into master:
# for remote
git-sweep cleanup
# for local
git remote add local $(pwd)
git-sweep cleanup --origin=local
- remove tags [#git #tags #script]:
# remote
git push --delete origin v2.5.4
# local
git tag -d v2.5.4
- get number of commits per author [#git #script #count]:
git shortlog -sne --no-merges
- get number of files in repo [#git #script #count]:
- get number of lines in repo [#git #script #count]:
git ls-files | xargs cat | wc -l
git ls-files | xargs wc -l # detailed
- work with
stash
[#git #stash]:
git stash show -p stash@{2}
git stash apply stash@{2}
git stash drop stash@{2}
- patch from uncommited changes [#git #patch]:
git diff --cached > mypatch.patch # --cached for staged changes
- revert modified file [#git #revert]:
- delete commits from history [#git #revert #remove #rebase]:
git rebase --onto <branch name>~<first commit number to remove> <branch name>~<first commit to be kept> <branch name>
git rebase --onto master~3 master~1 master
- delete all branches by pattern [#git #remove #branch]:
git branch --list 'temp*' | xargs git branch -D