本篇文章记录个人使用Git 的注意事项
GitHub SSH Key(Windows)
Generating a new SSH key and adding it to the ssh-agent - GitHub Docs
- 检查是否已有ssh key
$ sh -al ~/.ssh
# List the files in your .ssh directory, if they exist
- id_rsa.pub
- id_ecdsa.pub
- id_ed25519.pub
- 生成密钥(Use email as a label)
$ ssh-keygen -t ed25519 -C "your_email@example.com"
or $ ssh-keygen -t rsas -b 4096 -C "your_email@example.com"
具体的密钥文件可以去它提示的路径离找到
剩下的不想弄直接回车 就默认/默认没有
- 添加到代理"Auto-launchingin "Working with SSH key passphrases", or manually:
# start the ssh-agent in the background
$ eval "$(ssh-agent -s)"
> Agent pid xxxxxx
#Add SSH private key 文件名
$ ssh-add ~/.ssh/id_ed25519
- 把ssh-key添加到自己账户
在网页上操作,"头像 - Settings - SSH and GPG keys-New SSH key "
"Title"自己取 "Key"就把上面产生密钥的文件.pub 文件的内容全部复制 粘贴上就好
- 检查是否成功
$ ssh -T git@github.com然后需要输入Yes
要是在别的机子上不好使了,就重新add一下或者重新开开自己的ssh-agent服务
Your ssh key most likely had been removed from ssh agent
ssh-add ~/.ssh/id_rsa
where id_rsa is a ssh key associated with git repo
Update
You may get Could not open a connection to your authentication agent. error to resolve that you need to start the agent first by:
eval `ssh-agent -s`
提交代码
👍习惯性的在bash里面pull一下,在代码中解决一下可能会出现的冲突,然后再在IDEA里面add,commit,push
git push 与 git fetch
新建仓库提交代码
当找不到分支的时候 先git fetch 获取分支
然后 git checkout 或者 git switch 再不行就-f
git add .
git commit -m ""
git remote add -u origin git@........git
git push -u origin
切分支
👍必须要进入到以下载的文件夹里面