前言
上一篇架好了 Bonobo Git Server 6.5.0
要 migrate Git repository (repositories)
Git CLI
一定要用 Git CLI,海豚一直用 sourcetree,安裝時已附帶Git Bash 即Git 的 command prompt
唯獨最後1~2步必須用 Git command line
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 --mirror origin
Git Clone
Git Clone 有很多方法,用平常慣用的 Git Client 便可
例如 SourceTree 、 VS Git 、Git GUI
比如豚要clone QMS repository
Git GUI
當時豚犯了一個錯誤,本機的repository 未pull到最新
所以抄出來的 Testing 2少一項commit
Clone 打開 Git Bash跑那兩句,轉 push 目的地和 push
git remote set-url origin <URL to my NEW repo location>
git push --mirror origin
SourceTree
一樣都是 Cloneremote set-url origin 可以經UI做,setting > edit
或按Terminal 打開Git Bash
git remote set-url origin <URL to my NEW repo location>
git push --mirror origin
事入username 和password
預期push --mirror 完成的結果
Verify 確認一次
入錯 Password
有留意細節的也看到,不知為什麼 SourceTree的Git Bash 分兩次問 username,password
Git GUI 打開的Git Bash 是一個Dialog一次過問 username,password
pwd 入錯,豚估3種可能,
- 錯的,會記着,下次一直錯的
- 對的,會記着,下次免輸入
- 錯的不會記,下次再開 user credentials
- 對的不會記,每次問 user credentials
假如要搬很多 repositories,而 repository 來自不同git server,有不同 user credentials
如它會記 user credentials 就麻煩,海豚順便找一下如何清記錄
if $ git config credential.helper returns manager, the password is stored in the windows credential manager, if it returns store, password is stored in a .git-credentials file in the user folder.
輸入 git config credential.helper
如結果是 manager 就儲存在 windows credential manager
如結果是 store 就儲存在 .git-credentials
It is located at %UserProfile%\.git-credentials, which corresponds to C:\Users\<username>\.git-credentials
豚的 git password 會記在系統,英文windows 直接search windows credential manager 就有
中文windows 搜英文是沒有的,要由control panel 進去
windows credential manager > Windows Credentials
刪除
Reference
Where is my remote git repository password stored on the local machine?
https://stackoverflow.com/questions/42584934/where-is-my-remote-git-repository-password-stored-on-the-local-machine
How to migrate GIT repository from one server to a new one
https://stackoverflow.com/questions/1484648/how-to-migrate-git-repository-from-one-server-to-a-new-one
No comments:
Post a Comment