Windows端
初始化
下载Git,在任意文件夹右键菜单打开git bash,输入以下内容完成配置:
$ git config --global user.name "Your Name"
$ git config --global user.email "email@example.com"
和GitHub连接
让我们来问问聪明的ChatGPT怎么说吧:
You
git怎么生成ssh,怎么和GitHub连接
ChatGPT
Generate SSH key:
Runssh-keygen -t rsa -b 4096 -C "your email@example.com"
in the terminal
Enter a directory to save the key and a password (or leave empty if desired)
Add SSH key to GitHub account:
Copy the contents of your key withcat ~/.ssh/id_rsa.pub
to clipboardGo to GitHub account settings, select SSHKeys and add a new one with copiedcontents and a label.Test connection to GitHub by runningssh -T git@github.com
.
克隆服务器库
$ git clone "ssh://git@<srv_ip>:<port>/~/srv/<git_name>.git"
小妙招
# 发送wsl当前工作区存档到win桌面
$ git archive -o workspace.zip HEAD && mv workspace.zip /mnt/c/Users/zhy/Desktop/
这么做的好处在于,他会忽略gitignore也忽略的内容,用来做代码存档很好用。