2020-07-24 git 使用 windows 配置使用

1,先创建一个账号
2,新建一个仓库地址

图片.png

然后在git命令行输入命令:$ ssh-keygen -t rsa -C "你的注册邮箱@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa):
Created directory '/c/Users/Administrator/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/Administrator/.ssh/id_rsa.
Your public key has been saved in /c/Users/Administrator/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:BPfBOQb9aNdSxIxasBq7rgYfnQULTR7qJSMXsWR1U0E [email protected]
The key's randomart image is:
+---[RSA 2048]----+
| =+==E. |
| o.Bo+
+o + |
| . .=+o o |
| + =.+= + . |
| ..S+ . . |
| . . o. |
| o .. |
| o. |
| .... |
+----[SHA256]-----+

进入git文件夹
Administrator@EDZ-20180311VZF MINGW64 /
$ cd ~/.ssh

Administrator@EDZ-20180311VZF MINGW64 ~/.ssh
pwd
/c/Users/Administrator/.ssh
查看公钥
Administrator@EDZ-20180311VZF MINGW64 ~/.ssh
$ cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9aKI8QIeFybFeTTF8EqXopE6lvU3sXn4/omTz/Q 6aEvgM7AYPjYOVjZqBwSaZS7Wsh+V1xmFtUeUI5cy9mkiTlfOLB9yq66DmBEjesmw/LyiWYk28wL2i me0e0QitTRvRZkjIjSldbAf/VGUHBqC6SqWrr8T7l0obeGwiXZt+e7eSfUNVvxLGwt0ueMr/D23oXD Nrt2EsAvvIJisyVXxgJXlaueBZ75iLuatXUsUxeSAh0VWakuQKGnd+Nni3jDmja43TCQjiRmjbJgKc jOxPjPUt3vcitoSrsAwFAFnUMztaowC23pPdQ1epvFRv+FK62CP3f9K5rgniIVU39sLZ @qq.com

在创建的仓库上粘贴公钥地址

多个用户就要配置 config
Administrator@EDZ-20180311VZF MINGW64 ~/.ssh
$ pwd
/c/Users/Administrator/.ssh

Administrator@EDZ-20180311VZF MINGW64 ~/.ssh
$ vim config

Administrator@EDZ-20180311VZF MINGW64 ~/.ssh
$ vim config

Administrator@EDZ-20180311VZF MINGW64 ~/.ssh
$ cat config
Host github.com
HostName github.com
User hanmoxuangithub
IdentityFile /c/Users/Administrator/.ssh/id_rsa

在自己电脑创建一个你自己的线下仓库文件夹
Administrator@EDZ-20180311VZF MINGW64 /d
$ pwd
/d

Administrator@EDZ-20180311VZF MINGW64 /d
$ cd muke/

Administrator@EDZ-20180311VZF MINGW64 /d/muke
$ pwd
/d/muke

克隆仓库到本地
Administrator@EDZ-20180311VZF MINGW64 ~
$ git clone [email protected]:hanmoxuangithub/AutoTest001.git
Cloning into 'AutoTest001'...
The authenticity of host 'github.com (13.250.177.223)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Please type 'yes' or 'no': yes
Warning: Permanently added 'github.com,13.250.177.223' (RSA) to the list of known hosts.

warning: You appear to have cloned an empty repository.

在AutoTest001里面创建一个测试的文加
并查询这个文件夹的状态发现有一个文件没有被追踪
Administrator@EDZ-20180311VZF MINGW64 /d/muke/AutoTest001 (master)
$ vim test.txt

Administrator@EDZ-20180311VZF MINGW64 /d/muke/AutoTest001 (master)
$ ll
total 1
-rw-r--r-- 1 Administrator 197121 22 七月 24 22:31 test.txt

Administrator@EDZ-20180311VZF MINGW64 /d/muke/AutoTest001 (master)
$ git status
On branch master

No commits yet

Untracked files:
(use "git add ..." to include in what will be committed)

    test.txt

nothing added to commit but untracked files present (use "git add" to track)

使用追追踪命令:
Administrator@EDZ-20180311VZF MINGW64 /d/muke/AutoTest001 (master)
$ git add test.txt
warning: LF will be replaced by CRLF in test.txt.
The file will have its original line endings in your working directory.

Administrator@EDZ-20180311VZF MINGW64 /d/muke/AutoTest001 (master)
$ git status
On branch master

No commits yet

Changes to be committed:
(use "git rm --cached ..." to unstage)

    new file:   test.txt

增加描述文件:发现一个问题 需要提供自己的邮箱和账户名
Administrator@EDZ-20180311VZF MINGW64 /d/muke/AutoTest001 (master)
$ git commit -m "增加测试文件"

*** Please tell me who you are.

Run

git config --global user.email "[email protected]"
git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'Administrator@EDZ-20180311VZF.(none)')

输入邮箱账户名:
Administrator@EDZ-20180311VZF MINGW64 /d/muke/AutoTest001 (master)
$ git config --global user.email "邮箱@qq.com"

Administrator@EDZ-20180311VZF MINGW64 /d/muke/AutoTest001 (master)
$ git config --global user.name "账户名"

增加描述成功
Administrator@EDZ-20180311VZF MINGW64 /d/muke/AutoTest001 (master)
$ git commit -m "增加测试文件"
[master (root-commit) f1781a3] 增加测试文件
1 file changed, 1 insertion(+)
create mode 100644 test.txt

推送到云端成功:

Administrator@EDZ-20180311VZF MINGW64 /d/muke/AutoTest001 (master)
$ git push
Counting objects: 3, done.
Writing objects: 100% (3/3), 236 bytes | 236.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To github.com:hanmoxuangithub/AutoTest001.git

  • [new branch] master -> master
图片.png

拉取云端代码:
Administrator@EDZ-20180311VZF MINGW64 /d/muke/AutoTest001 (master)
$ git pull
Warning: Permanently added the RSA host key for IP address '13.229.188.59' to the list of known hosts.
Already up to date. 代表以及更新完毕

你可能感兴趣的:(2020-07-24 git 使用 windows 配置使用)