Collection of Tips for Git#

Update:

2023-05-05

How to switch from http clone to ssh after cloning#

Status check command:

$ git remote -v

Command to switch to ssh:

$ git remote set-url origin git@github.com:user/repo.git

Dealing with line ending warnings#

Line ending warning:

warning: LF will be replaced by CRLF in …
The file will have its original line endings in your working directory

To avoid this warning:

git config --global core.autoCRLF false

Avoiding garbled characters in Japanese paths:

git config --global core.quotepath false

How to connect to Github from the command line#

  • Creating a key pair

ssh-keygen -t ed25519 -C "username@email.com"
  • Log in to Github and register the public key. The following command can save it to the clipboard:

clip < ~/.ssh/id_ed25519.pub
  • Modifying ssh settings

~/.ssh/config#
Host my.github.com
    HostName github.com
    User git
    Port  22
    Hostname  github
    IdentityFile  ~/.ssh/id_ed25519
    TCPKeepAlive    yes
    IdentitiesOnly     yes
  • Checking Github connection

ssh -T git@my.github.com

Github Command Error Related#

troubleshooting

Note

ssh-keygen -R github.com というコマンドで直った経験あり