$ sudo apt-get install git
$ brew install git
$ git config --global user.name "username"
$ git config --global user.email "email"
$ ls ~/.ssh
若存在以下文件,则可省略下一步骤!!!
$ ssh-keygen -t rsa -C "email"
$ cat ~/.ssh/id_rsa.pub
添加key:
1. 打开网址并登录:github.com
2. 打开 settings -> SSH and GPG keys -> SSH keys
3. 点击 New SSH Key,完成输入。
$ ssh -T git@github.com
打开:https://github.com/
新建:New
$ echo "#example" >> README.md
$ git init
$ git add README.md
$ git commit -m "first commit"
$ git branch -M main
$ git remote add origin git@github.com:ChriserChen/example.git
$ git push -u origin main
git add README.md
git commit -m "commit"
git push -u origin main
$ git remote -v
$ git pull origin master
// 从远程拉取最新版本到本地,不自动合并
git fetch origin master
git log -p master ../origin/master
git merge orgin/master
原文:https://www.cnblogs.com/chen-jia-cheng/p/14835427.html