-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the sillydanny.github.io wiki!
Make sure there is at least one file in it (even just the README.md)
ssh-keygen -t rsa -C "your_email@example.com"
or even better:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
It also possible to use ed25519. There are pros and cons, but personally I've had some issues and that is the reason I've chosen to stick to 4096 rsa for now.
macOS:
pbcopy < ~/.ssh/id_rsa.pub
GNU/Linux (requires the xclip package):
xclip -sel clip < ~/.ssh/id_rsa.pub
Windows Command Line:
type %userprofile%\.ssh\id_rsa.pub | clip
Git Bash on Windows / Windows PowerShell:
cat ~/.ssh/id_rsa.pub | clip
or ofcourse copy it via your favorite editor, cat, or whatever suits your needs :)
Copy the contents of the to your SSH keys to your GitHub account settings (https://github.com/settings/keys).
ssh -T git@github.com
Change directory into the local clone of your repository (if you're not already there) and run:
git remote set-url origin git@github.com:username/your-repository.git
Now try editing a file (try the README) and then do:
git add -A
git commit -am "Update README.md"
git push
Add the key to the ssh-agent
ssh-add ~/.ssh/id_rsa
You should not be asked for a username or password. If it works, your SSH key is correctly configured.
Git 更換遠端伺服器倉庫網址URL
1.確認目前Git遠端伺服器網址: git remote -v
git remote -v
origin https://github.com/USERNAME/REPOSITORY.git (fetch)
origin https://github.com/USERNAME/REPOSITORY.git (push)
2.更換Git遠端伺服器位網址,使用:git remote set-url
git remote set-url origin https://github.com/USERNAME/OTHERREPOSITORY.git
3.再次確認Git遠端伺服器網址
git remote -v
origin https://github.com/USERNAME/OTHERREPOSITORY.git (fetch)
origin https://github.com/USERNAME/OTHERREPOSITORY.git (push)
如果是使用SSH的存取網址,指令一樣是使用git remote set-url,再接上新的SSH URL就可以更換,指令如下:
git remote set-url origin git@github.com:USERNAME/OTHERREPOSITORY.git
不管是要HTTP/HTTPS跟SSH,二種存取網址都是可以直接做更換,然後下次git push/ git fetch 就會到新設定的網址去了唷。