5
Tools/Git
Fan-Wu Geoffrey Yang edited this page 2026-09-29 15:37:02 +13:00

Git Info


Mirroring Repos

This mirrors a repo to your current repo

Explanation
`git remote add {name_of_remote} {remote_url}`
Adds a remote to your instance under {name_of_remote} (any unique name you decide) which will mirror {remote_url} to your repo.

git push origin 'refs/remotes/{name_of_remote}/:refs/heads/' --prune --tags
Pushes your remote and prunes all current branchs that don't exist on the remote anymore.
Warning! This means that all local work on that mirror can be lost. Generally I would recommend you don't work directly on the mirror repo. So the repo will looking like: Original > Mirrored Repo > Your Fork.
git remote add {name_of_remote} {remote_url}
git fetch {name_of_remote}
git push origin 'refs/remotes/{name_of_remote}/:refs/heads/' --prune --tags

Renaming Already Pushed Commits

Explanation `git rebase -i HEAD~{number_of_commits_to_go_back}` git rebase interactively (commit by commit) from current head to number of commits ago.

git push --force-with-lease

git force push but only if there are no new commits

git rebase -i HEAD~{number_of_commits_to_go_back}
git push --force-with-lease

References: