Git 設置配置用戶名/郵箱,生成SSH key,切換遠端協議https ssh


一、設置user.name 和 user.email

  1.查看user.name和user.email

    git config --list     //查看配置

    git config user.name

    git config user.email

  2.配置user.name  和 user.email(global為全局配置)

    git config --global user.name  "myname"

    git config --global user.email  "myemail@163.com"

二、設置SSH Key

  1.查看本地是否已經有ssh文件(pub文件)

    我的文檔   --->  .ssh目錄下。id_rsa、id_rsa.pub文件

  2.生成ssh key

     ssh-keygen -t rsa -C "myemail@163.com"

  3.添加到Github ssh配置中。
三、切換https和ssh協議(.git 下config文件)

  1. 查看當前remote

    git remote -v

  2. 切換到https:

    git remote set-url https://github.com/yourusername/repository.git

  3. 切換到ssh:

    git remote set-url git@github.com:yourusername/repository.git

四、https協議,密碼緩存。(我的文檔下.gitconfig文件)公司vpn連接時,只能用https協議。

  git config --global credential.helper store

五、git設置短命令

  git config --global alias.st status

  git config --global alias.co checkout
  git config --global alias.ci commit
  git config --global alias.br branch
  git config --global alias.ps push
  git config --global alias.pl pull

 
 

  

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM