Git版本控制

本文最后更新于:2022年7月14日 上午

Git 各区域命令

工作区

  • git clone
  • git init
  • git add
  • git pull
  • git push
  • git fetchfetch到FETCH_HEAD
  • git checkout
  • git log
  • git reflog本地所有变更(checkout,reset^HEAD)的日志
  • git config/status
  • git status

版本库

stage

  • git reset
  • git checkout
  • git stash (apply)暂存/还原
  • git rm
  • git status

    master

  • git branch
  • git merge
  • git diff
  • git remote
  • git rebase
  • git reset

SSH

SSH key

生成key并保存到指定位置

ssh-keygen -t rsa -b 4096 -C "xxx@gmail.com"

Host配置

# ~/.ssh/config

Host github1
  HostName github.com
  User SiynMa
  PreferredAuthentications publickey
  IdentityFile ~/.ssh/id_rsa_gmail

Host github2
  HostName github.com
  User SiynMa2
  PreferredAuthentications publickey
  IdentityFile ~/.ssh/id_rsa_qqmail

多SSH Host密钥对使用

  • 分别使用两个密钥clone
    git clone git@github1:JedWatson/classnames.git
    git clone git@github2:JedWatson/classnames.git
  • 配合remote别名
    git remote rename github.com github1

开发中断

  1. git stash
  2. git reset --hard head
  3. git checkout -- <file>

.gitignore配置


Git版本控制
http://yoursite.com/2022/07/13/git/
作者
tatekii
发布于
2022年7月13日
许可协议