欢迎来到 Mofei Wang的小站! 这是我的第一篇文章.
本文记录一些GIT常用命令,以供不时之需


常用Github部署命令

一键克隆

1
2
cd Desktop\hexo
git clone git@github.com:Wangmofei/hexo.git

一键三连

1
h clean && h generate && h s

部署三连

1
2
3
4
5
6
7
echo "# favorite" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin git@github.com:Wangmofei/favorite.git
git push -u origin main

回滚三连

1
2
3
4
5
6
😊回退到上个版本
git reset --hard HEAD^
😊回退到三次前版本
git reset --hard HEAD~3
😊回退到指定commitID版本
git reset --hard commit_id

雅安三连

1
2
3
npm install -g yarn --registry=https://registry.npm.taobao.org
yarn config set registry https://registry.npm.taobao.org -g
yarn config set sass_binary_site http://cdn.npm.taobao.org/dist/node-sass -g

常用Github授权命令

为PC生成公钥

  1. 检查本机是否已有公钥
    1
    ls -la ~/.ssh
  2. 将原来的公钥删除
    1
    rm -rf ~/.ssh
  3. 生成新的公钥(填自己的邮箱),然后除了密码,一路默认
    1
    ssh-keygen -t ras -C "wangmofei@sina.com"
  4. 在默认的路径下便生成了自己的id_ras.pub,查看id_ras.pub的内容
    1
    cat path/to/id_ras.pub
  5. 将id_rsa.pub中的内容拷贝在Github中授权
    打开Github,点击头像->Setting
    点击左边栏的SSH and GPG keys
    SSH keys右边点击New SSH key
    填入一个SSH key的title, key框内粘贴如上一步来自PC的id_ras.pub内容