github ssh key添加方法和简单git 命令收藏

本文指导用户如何在Mac和PC上创建SSH Key,并将其添加到GitHub账户,以便安全地进行版本控制操作。步骤包括在终端中生成SSH Key,将Key复制到剪贴板,然后在GitHub设置中添加Key。此外,文章还简单介绍了Git的四个基本操作:创建分支、添加文件、保存更改和同步到GitHub。
For MAC Users:

To create an SSH Key, go to your terminal (or iTerm 2) and enter ssh-keygen. You will be prompted for a file in which to save the key (.ssh/id_rsa). There’s no need to enter anything, just press enter. When prompted for a passphrase, you can enter one or just press enter to ignore creating a passphrase.

Your SSH key has been saved to ssh/id_rsa.pub, run the command pbcopy < ~/.ssh/id_rsa.pub to copy this to your clipboard.

Now go to your Github account setting for Key: https://github.com/settings/keys and click ‘New SSH key’. Add any title you want, like ‘First SSH Key’, paste in your SSH key, and click the ‘Add SSH key’ button.

For PC Users:

To create an SSH Key, go to your terminal and enter ssh-keygen. You will be prompted for a file in which to save the key (.ssh/id_rsa). There’s no need to enter anything, just press enter. When prompted for a passphrase, you can enter one or just press enter to ignore creating a passphrase.

Your SSH key has been saved to ssh/id_rsa.pub, run the command cat ~/.ssh/id_rsa.pub to see your SSH key in the proper format. Copy the whole text string starting with ‘ssh’ to the end.

Now go to your Github account setting for keys: https://github.com/settings/keys and click ‘New SSH key’. Add any title you want, like ‘First SSH Key’. Paste your SSH key to the Key window, and click the ‘Add SSH key’ button.

There are a lot of complex functionalities of Git, but for 99% of work there are 4 things that you need to be able to do:

  1. Create a branch git checkout -b my-branch-name

  2. Add files that you want to queue up for saving.

    • To add all files: git add .

    • To add a specific file: git add path-to-file

  3. Save (commit) changes to the files that you added above. git commit -m "message about this commit. Ex: change button color to green."

  4. Sync your branch to Github so that you can later make a pull request. git push -u origin my-branch-name

更多精彩文章:
https://datasciencebyexample.com/
datascience tribe

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值