The following command is used to remove the backup of your Git repository created by the git filter-branch
command.
rm -rf .git/refs/original/
The following command changes the author and committer dates of all commits in all branches and tags to "07/06/2024 16:14:00".
git filter-branch -f --env-filter '
export GIT_COMMITTER_DATE="07/06/2024 16:14:00"
export GIT_AUTHOR_DATE="07/06/2024 16:14:00"
' --tag-name-filter cat -- --all
The following command force pushes all branches to the remote repository named origin
.
git push origin --force --all
The following commands are used to create a new branch with a new initial commit (new history), delete the old branch, and force push the new branch to the remote repository.
git checkout --orphan newBranch
git add -A
git commit -m "Initial commit"
git branch -D main
git branch -m main
git push -f origin main
Replace main
with the name of your default branch if it's not main
.
The following commands are used to modify the author and committer dates of a specific commit identified by its hash.
git rebase -i 3aac782a16123ccc95fd7547911e806ee434ffd9
GIT_COMMITTER_DATE="07/06/2024 13:14:00" GIT_AUTHOR_DATE="07/06/2024 13:14:00" git commit --amend --no-edit --date "07/06/2024 13:14:00"