git的常用命令

generate key

1
2
3
4
5
6
mkdir .ssh
cd .ssh
ssh-keygen -t rsa -C "my.email@example.com" -b 4096
# iinux
chmod 0700 ~/.ssh
chmod 0600 ~/.ssh/id_rsa*

copy key

1
cat ~/.ssh/id_rsa.pub

Git Bash on Windows / Windows PowerShell

1
cat ~/.ssh/id_rsa.pub | clip

Git test

1
2
ssh -T git@github.com
# Hi co-py You've successfully authenticated, but GitHub does not provide shell access.

clone git res

1
git clone 'git@myproject.git'

check status

1
git status -s

commit

1
2
3
4
5
git init
git add .
git commit -m 'feat # init'
git remote add origin 'git@myproject.git'
git push origin master

reset

1
git reset -hard 'log.hash'

error

1
2
3
4
5
6
ssh-agent bash
ssh-add id_rsa
# ssh: Could not resolve hostname ssh.github.com: Name or service not known
step1. ping github.com
step2. sudo nano /etc/hosts
add 192.30.252.128 github.com