Last active
March 18, 2020 18:40
-
-
Save mathieucarbou/1dda3807bc1b1cfaec4b7087d7ec9888 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# GIT | |
# Aliases in ~/.gitconfig | |
oldest-ancestor = !bash -c 'diff --old-line-format='' --new-line-format='' <(git rev-list --first-parent "${1:-master}") <(git rev-list --first-parent "${2:-HEAD}") | head -1' - | |
########################################### | |
# Fix authors after rebase: | |
git filter-branch -f --commit-filter 'export GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; git commit-tree "$@"' -- 7d71041028501aeb33613bd06adcb3de69cabb0f..HEAD | |
# find base | |
git log --pretty=format:%H | tail -1 | |
# Removing files | |
git filter-branch -f --prune-empty --tree-filter "find . -name license.xml -delete” HEAD | |
# Searching for text | |
git log -SSoftwareAG_License | |
# List authors | |
git log --format='%aN <%aE>' | sort -u | |
########################################### | |
# Only keep commits and commit content from feature branch for the 3 dynamic-config subfolders: | |
# WARNING: WORK ON A BRANCH COPY | |
ANCESTOR=`git oldest-ancestor master` | |
# number of commits to rework and prune | |
git log --pretty=oneline $ANCESTOR..HEAD | wc -l | |
# do the removal | |
git filter-branch -f --prune-empty --tree-filter 'find . -maxdepth 1 -not -name "dynamic-config" -exec rm -f -r "{}" \;' $ANCESTOR..HEAD | |
git filter-branch -f --prune-empty --tree-filter 'rm -f -r (!dynamic-config)' $ANCESTOR..HEAD | |
########################################### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment