Git下载、安装与环境配置

一.git下载与安装

1.百度git官网,git官网,根据自己电脑系统下载相应的安装包
在这里插入图片描述2.点击下载好的安装包安装这个软件
3.一直点击next,直到出现install,点击install,安装完成后点击finish:
4.检查git是否安装OK,windows+r,然后在弹出框中出入cdm,弹出如下界面,输入git,回车,弹出上图所示界面就说明安装成功

C:\Users\27800>git
usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]

These are common Git commands used in various situations:

start a working area (see also: git help tutorial)
   clone             Clone a repository into a new directory
   init              Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)
   add               Add file contents to the index
   mv                Move or rename a file, a directory, or a symlink
   restore           Restore working tree files
   rm                Remove files from the working tree and from the index
   sparse-checkout   Initialize and modify the sparse-checkout

examine the history and state (see also: git help revisions)
   bisect            Use binary search to find the commit that introduced a bug
   diff              Show changes between commits, commit and working tree, etc
   grep              Print lines matching a pattern
   log               Show commit logs
   show              Show various types of objects
   status            Show the working tree status

grow, mark and tweak your common history
   branch            List, create, or delete branches
   commit            Record changes to the repository
   merge             Join two or more development histories together
   rebase            Reapply commits on top of another base tip
   reset             Reset current HEAD to the specified state
   switch            Switch branches
   tag               Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)
   fetch             Download objects and refs from another repository
   pull              Fetch from and integrate with another repository or a local branch
   push              Update remote refs along with associated objects

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.
See 'git help git' for an overview of the system.

弹出上图所示界面就说明安装成功

二.环境配置

1.git安装好去GitHub上注册一个账号,注册好后,点击桌面上的Git Bash快捷图标,我们要用账号进行环境配置

# 配置用户名
git config --global user.name "username"    //( "username"是自己的账户名,)
# 配置邮箱
git config --global user.email "username@email.com"     //("username@email.com"注册账号时用的邮箱)

2.以上命令执行结束后,可用 git config --global --list 命令查看配置是否OK

jack@DESKTOP-DVU0UQ9 MINGW64 ~/Desktop
$ git config --global --list
user.name=username
user.email=username@email.com

3.生成ssh,继续刚才的操作,在命令框中输入以下命令ssh-keygen -t rsa,
然后连敲三次回车键

jack@DESKTOP-DVU0UQ9 MINGW64 ~/Desktop
$ ssh-keygen -t rsa
Generating public/private rsa key pair.

Enter file in which to save the key (/c/Users/27800/.ssh/id_rsa): Created directory '/c/Users/27800/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/27800/.ssh/id_rsa
Your public key has been saved in /c/Users/27800/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:DIia1Cg2dJ/6X/+QLVS4k6bNDXGbTVnniE0HXsk2+xM jack@DESKTOP-DVU0UQ9
The key's randomart image is:
+---[RSA 3072]----+
| . .          +.*|
|. +....     .= X+|
|.=...o.    o.o=o+|
|+o. .  o    * =E |
|o  .    S  B o .o|
|    .     * *  ..|
|     .   o * o  .|
|      . . . o    |
|       .   ...   |
+----[SHA256]-----+

4.去系统盘目录下(一般在 C:\Users\你的用户名.ssh)(mac: /Users/用户/.ssh)查看是否有。ssh文件夹生成,此文件夹中以下两个文件在这里插入图片描述5. 将ssh文件夹中的公钥( id_rsa.pub)添加到GitHub管理平台中,在GitHub的个人账户的设置中找到如下界面,title随便起一个,将公钥( id_rsa.pub)文件中内容复制粘贴到key中,然后点击Ass SSH key就行了
在这里插入图片描述

6.测试一下配置是否成功,在Git Bush命令框(就是刚才配置账号和邮箱的命令框)中继续输入以下命令,回车,出现错误

jack@DESKTOP-DVU0UQ9 MINGW64 ~/Desktop
$ ssh -T git@github.com
The authenticity of host 'github.com (192.30.255.113)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com,192.30.255.113' (RSA) to the list of known hosts.
Hi 151706166744! You've successfully authenticated, but GitHub does not provide shell access.

7.提示:The authenticity of host ‘github.com (192.30.255.113)’ can’t be established. 因为少了一个known_hosts文件,本来密钥文件应该是三个,现在是两个,便报了这样的错误,此时选择yes回车之后,便可,同时生成了缺少了的known_hosts文件,这时候便成功了

jack@DESKTOP-DVU0UQ9 MINGW64 ~/Desktop
$ ssh -T git@github.com
Warning: Permanently added the RSA host key for IP address '192.30.255.112' to the list of known hosts.
Hi 151706166744! You've successfully authenticated, but GitHub does not provide shell access.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值