These commands may help when dealing with old and complicated Git repositories. I used them to build a new branch to streamline a more readable history for a 20-year-old project.
git difftool -d <commit-a>:path/to/dir1 <commit-b>:path/to/dir2
git diff --stat <commit-a> <commit-b>
git diff --no-index <path1> <path2>
git cherry master -v | head -n 1
git show -s --format="%cd" <commit>
or
git show -s --format="%ci" <commit>
git show -s --format="%ad" <commit>
or
git show -s --format="%ai" <commit>
GIT_COMMITTER_DATE="<committer-date>" git commit --amend --author="Author Name <[email protected]>" --date "<author-date>"
git merge --allow-unrelated-histories <other-branch>
git rebase --committer-date-is-author-date --onto <newbase>
Replace <startcommit>
with SHA or short SHA of the commit which should be considered as stable foundation.
git filter-branch --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 "$@"' -- <startcommit>..HEAD
Once you've inspected the results, and you're really sure that you have what you want, you can remove the backed up ref…
git update-ref -d refs/original/refs/heads/<branchname>
… or add -f
option to the git filter-branch
command
git filter-branch -f --commit-filter ...