Hiển thị các bài đăng có nhãn git ssh. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn git ssh. Hiển thị tất cả bài đăng

Chủ Nhật, 19 tháng 4, 2020

Cách git clone từ ssh | git clone ssh://git@github.com//.git

Để git source code thông qua ssh:
git clone ssh://git@github.com/<user>/<repository name>.git
Nếu lỗi xảy ra:

fatal: destination path 'ssh://user@server:/GitRepos/myproject.git' already exists and is not an empty directory.

Fix:
For setting up git to clone via ssh see:

1. Kiểm tra xem git đã có ssh key chưa:
$ ls -al ~/.ssh
# Lists the files in your .ssh directory, if they exist
Nếu có thì nó sẽ có file .pub như sau:
  • id_rsa.pub
  • id_ecdsa.pub
  • id_ed25519.pub
2. Nếu chưa có ssh key thì phải add
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
email: là email bạn đăng ký git
Tiếp:
Enter a file in which to save the key (/c/Users/you/.ssh/id_rsa):[Press enter]
Thêm mật khẩu:
Enter passphrase (empty for no passphrase): [Type a passphrase]
> Enter same passphrase again: [Type passphrase again]

3. Add ssh-key vào ssh-agent
$ eval $(ssh-agent -s)
$ ssh-add ~/.ssh/id_rsa