Git仓库完全迁移
简单的4行代码,完成git创库的迁移。
git clone --mirror <URL to my OLD repo location>
cd <New directory where your OLD repo was cloned>
git remote set-url origin <URL to my NEW repo location>
git push -f origin
实验一波,是不是很完美。
注意
一般提交的时候不要git push -f origin
, 是一个需要谨慎的操作,它是将本地历史覆盖到远端仓库的行为。
当然也并非禁止,有时,如果代码组内review后,确认代码正确无误,保证大家未pull的情况下,强制推送后,可以保持目录树清洁