一、下载:
Git官网链接https://git-scm.com/;
二、简介:
Git是一款免费、开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目。Git的功能特性:
从一般开发者的角度来看git有以下功能:
1:从服务器上克隆数据库(包括代码和版本信息)到单机上。
2:在自己的机器上创建分支,修改代码。
3:在单机上自己创建的分支上提交代码。
4:在单机上合并分支。
5:新建一个分支,把服务器上最新版的代码fetch下来,然后跟自己的主分支合并。
6:生成补丁(patch),把补丁发送给主开发者。
7:看主开发者的反馈,如果主开发者发现两个一般开发者之间有冲突(他们之间可以合作解决的冲突),就会要求他们先解决冲突,然后再由其中一个人提交。如果主开发者可以自己解决,或者没有冲突,就通过。
8:一般开发者之间解决冲突的方法,开发者之间可以使用pull 命令解决冲突,解决完冲突之后再向主开发者提交补丁。
三、下载后的操作:
Git可以不下载到C盘,下载完成后打开文件夹Git,双击其中的Git-bash,
打开后输入git则会得到如下提示:
usage: git [–version] [–help] [-C ] [-c =]
[–exec-path[=]] [–html-path] [–man-path] [–info-path]
[-p | –paginate | -P | –no-pager] [–no-replace-objects] [–bare]
[–git-dir=] [–work-tree=] [–namespace=]
[]
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
reset Reset current HEAD to the specified state
rm Remove files from the working tree and from the index
examine the history and state (see also: git help revisions)
bisect Use binary search to find the commit that introduced a bug
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
checkout Switch branches or restore working tree files
commit Record changes to the repository
diff Show changes between commits, commit and working tree, etc
merge Join two or more development histories together
rebase Reapply commits on top of another base tip
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 ’ or ‘git help ’
to read about a specific subcommand or concept.
这说明下载成功!
输入ssh-keygen -t rsa -C “****@example.com”,其中双引号中为注册GitHub时所用的邮箱,输入后回车;然后会出现以下提示:
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/DELL/.ssh/id_rsa):
不管他,继续回车,会出现以下提示:
Created directory ‘/c/Users/DELL/.ssh’.
Enter passphrase (empty for no passphrase):
仍旧不管,继续回车,会出现:
Enter same passphrase again:
不管,回车,然后会出现:
Your identification has been saved in /c/Users/DELL/.ssh/id_rsa.
Your public key has been saved in /c/Users/DELL/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:5IwFOt72K/0c1Ynnu2jSk8hCJnFzawecB4o4q2a4R8Y 3066536916@qq.com
The key’s randomart image is:
+—[RSA 2048]—-+
| . |
| . . . |
| o. .oo o |
| .ooo*+ = .o . |
| . .o+oSo +o + |
| E ….o o..o |
| + . =.o.+ .. |
|. = . oo+.=. . |
|.= ..ooo..o. |
+—-[SHA256]—–+
这部完成就可以到指定的文件夹中找id_rsa.pub文件(再输入第一句指令后的提示中有此文件路径),复制其中内容(和id_rsa.pub一起的应该还有一个id_rsa文件,不要复制错了)
四、在GitHub上进入 Account Settings(账户配置),左边选择SSH Keys,Add SSH Key,title随便填,粘贴在你电脑上生成的key。
为了验证是否成功,在git bash下输入:
$ ssh -T git@github.com
如果是第一次的会提示是否continue,输入yes就会看到:You’ve successfully authenticated, but GitHub does not provide shell access 。这就表示已成功连上github。