git remote set-url origin new.git.url/here Ref
git fetch origin git reset --hard origin/master Ref
git format-patch -1 Ref
- First the stats: git apply --stat a_file.patch
- Then a dry run to detect errors: git apply --check a_file.patch
- Finally, you can use git am to apply your patch: git am < a_file.patch Ref
git log --grep="pattern" Ref