git怎么模仿linux终端吗,如何使用git终端

检查是否存在SSH密码

Before you generate an SSH key, you can check to see if you have any existing SSH keys.

Windows

Open Git Bash.

Enter ls -al ~/.ssh to see if existing SSH keys are present:

$ ls -al ~/.ssh

# Lists the files in your .ssh directory, if they exist

Check the directory listing to see if you already have a public SSH key. By default, the filenames of the public keys are one of the following:

id_rsa.pub

id_ecdsa.pub

id_ed25519.pub

If you don‘t have an existing public and private key pair, or don‘t wish to use any that are available to connect to GitHub, then generate a new SSH key.

If you see an existing public and private key pair listed (for example id_rsa.pub and id_rsa) that you would like to use to connect to GitHub, you can add your SSH key to the ssh-agent.

Tip: If you receive an error that ~/.ssh doesn't exist, don't worry! We'll create it when we generate a new SSH key.

Linux

Open Terminal.

Enter ls -al ~/.ssh to see if existing SSH keys are present:

$ ls -al ~/.ssh

# Lists the files in your .ssh directory, if they exist

Check the directory listing to see if you already have a public SSH key. By default, the filenames of the public keys are one of the following:

id_rsa.pub

id_ecdsa.pub

id_ed25519.pub

If you don‘t have an existing public and private key pair, or don‘t wish to use any that are available to connect to GitHub, then generate a new SSH key.

If you see an existing public and private key pair listed (for example id_rsa.pub and id_rsa) that you would like to use to connect to GitHub, you can add your SSH key to the ssh-agent.

Windows

Open Git Bash.

Paste the text below, substituting in your GitHub email address.

$ ssh-keygen -t rsa -b 4096 -C "[email protected]"

This creates a new ssh key, using the provided email as a label.

> Generating public/private rsa key pair.

When you‘re prompted to "Enter a file in which to save the key," press Enter. This accepts the default file location.

> Enter a file in which to save the key (/c/Users/you/.ssh/id_rsa):[Press enter]

At the prompt, type a secure passphrase. For more information, see "Working with SSH key passphrases".

> Enter passphrase (empty for no passphrase): [Type a passphrase]

> Enter same passphrase again: [Type passphrase again]

Linux

打开终端。

粘贴以下文本,替换为您的GitHub电子邮件地址。

$ ssh-keygen -t rsa -b 4096 -C "[email protected]"

使用提供的电子邮件作为标签,这将创建一个新的ssh密钥。

> Generating public/private rsa key pair.

当提示您“输入要在其中保存密钥的文件”时,请按Enter。这接受默认文件位置。

> Enter a file in which to save the key (/home/you/.ssh/id_rsa): [Press enter]

在提示符下,键入一个安全密码。有关更多信息,请参阅“使用SSH密钥密码短语”。

> Enter passphrase (empty for no passphrase): [Type a passphrase]

> Enter same passphrase again: [Type passphrase again]

在将新的SSH密钥添加到ssh-agent来管理密钥之前,您应该已经检查了现有的SSH密钥并生成了一个新的SSH密钥。

在后台启动ssh-agent。

$ eval "$(ssh-agent -s)"

> Agent pid 59566

将SSH私钥添加到ssh-agent。如果您使用其他名称创建密钥,或者要添加具有其他名称的现有密钥,请使用私有密钥文件的名称替换命令中的id_rsa。

$ ssh-add ~/.ssh/id_rsa

打开gitbash终端

clip

然后在Key里复制粘贴,就会有key值出现

a49d65e9ea10b0860e310f914516e0ca.png

最后,在git终端下就可以copy我们的git仓库代码了

#git clone [email protected]:YourGitHub/YourProject.git

git clone [email protected]:CarryGitHub/Demo1.git

原文:https://www.cnblogs.com/CarryBlogs/p/12459466.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值