Git
Merge multiple commits
Merge multiple previous commits together in a single commit.
git rebase -i HEAD~[NUMBER OF COMMITS TO MERGE]
Then, replace pick
by squash
on lines you want to discard the log message. Finally, remove the commit messages you want to discard to avoid being left with a multiline commit.
Rewrite author history
Change the author name and email address of all your commits in the history.
git filter-branch --commit-filter '
if [ "$GIT_AUTHOR_EMAIL" = "original@email.address" ];
then
GIT_AUTHOR_NAME="New Name";
GIT_AUTHOR_EMAIL="new@email.address";
git commit-tree "$@";
else
git commit-tree "$@";
fi' HEAD
git push --force --tags origin HEAD:master
Warning
This will rewrite your git history!
Only keep a sub-directory
If you only need a specific sub-directory from a git repository, use the following command to prune everything else:
cd <git repository>
git filter-branch --prune-empty --subdirectory-filter <path to sub-dir> HEAD