git问题记录

Posted zjhgx

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了git问题记录相关的知识,希望对你有一定的参考价值。

从http切换到ssh,github在本地pull时发生

ERROR: Repository not found.

fatal: Could not read from remote repository.

总之遇到这种问题,把key重新生成一遍在github上重新加一次。具体

https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account

Generating a new SSH key

$ ssh-keygen -t ed25519 -C "your_email@example.com"

Adding your SSH key to the ssh-agent

 

  1. Start the ssh-agent in the background.

    $ eval "$(ssh-agent -s)"
    > Agent pid 59566

Add your SSH private key to the ssh-agent and store your passphrase in the keychain. If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_ed25519 in the command with the name of your private key file. $ ssh-add -K ~/.ssh/id_ed25519 Note: The -K option is Apple\'s standard version of ssh-add, which stores the passphrase in your keychain for you when you add an ssh key to the ssh-agent. If you chose not to add a passphrase to your key, run the command without the -K option. If you don\'t have Apple\'s standard version installed, you may receive an error. For more information on resolving this error, see "Error: ssh-add: illegal option -- K."

 

Copy the SSH public key to your clipboard.

If your SSH public key file has a different name than the example code, modify the filename to match your current setup. When copying your key, don\'t add any newlines or whitespace.

$ pbcopy < ~/.ssh/id_ed25519.pub


注意:因为我本地要上传两个github的账号,所以还必须在~/.ssh目录下增加config配置,不同key针对不同账号,把相应zjhgx.pub里面内容拷贝到github setting里的ssh and gpg keys.
  1 Host zjhgx163.github.com                                                                                                                                                                                                                            
  2     HostName github.com
  3     PreferredAuthentications publickey
  4     IdentityFile ~/.ssh/zjhgx163
  5 
  6 Host zjhgx.github.com
  7     HostName github.com
  8     PreferredAuthentications publickey
  9     IdentityFile ~/.ssh/id_ed25519

 

以上是关于git问题记录的主要内容,如果未能解决你的问题,请参考以下文章

VSCode自定义代码片段15——git命令操作一个完整流程

VSCode自定义代码片段15——git命令操作一个完整流程

如何删除 Git 仓库中的历史提交记录

使用 Git 来管理 Xcode 中的代码片段

markdown Git代码片段

行历史查看器 - Git