2021-02-02

Git Note

 久久一次換新電腦,要重新設定git環境,紀錄一下日後可以查找



  • 設定ssh

    1. 使用ssh-keygen
      D:\>ssh-keygen
      Generating public/private rsa key pair.
      Enter file in which to save the key (C:\Users\itlogs/.ssh/id_rsa):
      Enter passphrase (empty for no passphrase):
      Enter same passphrase again:
      Your identification has been saved in C:\Users\itlogs/.ssh/id_rsa.
      Your public key has been saved in C:\Users\itlogs/.ssh/id_rsa.pub.
      The key fingerprint is:
      SHA256:xxxxx
      The key's randomart image is:
      +---[RSA 2048]----+
      |            .o++o|
      |           .. o+=|
      |      .= .   .   |
      |      o+o        |
      +----[SHA256]-----+
      
    2. 產出了路徑會在 C:\Users\user-name/.ssh/
    3. 設定git使用windows的憑證存放區設定
      git config --global http.sslBackend schannel
      
    4. gitlab設定: user > setting > ssh keys 加入public key (id_rsa.pub)
    5. 取一個遠端數據庫的名稱
      git remote add <name> <url>
      git remote add itlogs https://xxx@gitlab.com/xxx/test.git
      
    6. 推上去

      git push <repository> <refspec>
      git push itlogs master
      
    7. 拉下來

      git pull <repository> <refspec>
      git pull itlogs master
      
    8. clone
      git clone <repository> <directory>
      git clone https://xxx@gitlab.com/xxx/test.git test
      

參考資料:
https://stackoverflow.com/questions/16668508/how-do-i-configure-git-to-trust-certificates-from-the-windows-certificate-store