初识GitHub

第一次使用Git

1. 注册账号

https://github.com/
·就正常的注册账号、邮箱、密码
·选择Free-Finish
·验证邮箱
新建一个仓库

2. 新建仓库

其实我用的是mymygit啦~但是不能重名所以这里显示的mymygitt,目前在GitHub上的操作到这里,接下来要做的是在Windows下安装Git,并与GitHub建立连接,将本地代码上传到刚刚建立的仓库

3. 安装Git(Windows)

下载地址 https://gitforwindows.org/
安装教程 http://www.cnblogs.com/wj-1314/p/7993819.html
安装成功桌面会有Git Bush的图标
在这里插入图片描述

4. 在本地建立自己的文件

我在pycharm里新建了一个hello.py
建立的文件其中.git 文件是在建立好连接后才出现的,现在无视他无视他~~

5. 本地文件与Git建立连接

(1)双击打开Git Bush
进入本地建立的文件夹位置cd d:/pygit/
(2)配置用户名和邮箱

4@DESKTOP-BUCB38P MINGW64 /d/pygit (master)
$ git config --global user.name "ZanLore"

4@DESKTOP-BUCB38P MINGW64 /d/pygit (master)
$ git config --global  user.email "1461946376@qq.com"

(3)初始化仓库
使用git init初始化,此时**.git文件**出现在pygit文件夹下,这个目录变成了Git可以管理的仓库

4@DESKTOP-BUCB38P MINGW64 /d/pygit
$ git init
Initialized empty Git repository in D:/pygit/.git/

(4)检查状态

4@DESKTOP-BUCB38P MINGW64 /d/pygit (master)
$ git status
On branch master

No commits yet

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

        .idea/
        hello.py
        venv/

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

(5)将文件添加进仓库git add .
注意add和.之间有空格喔~

4@DESKTOP-BUCB38P MINGW64 /d/pygit (master)
$ git add .
warning: LF will be replaced by CRLF in .idea/workspace.xml.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in venv/tensorflowTest/Lib/site-packages/pip-10.0.1-py3.5.egg/EGG-INFO/SOURCES.txt.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in venv/tensorflowTest/Lib/site-packages/pip-10.0.1-py3.5.egg/EGG-INFO/dependency_links.txt.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in venv/tensorflowTest/Lib/site-packages/pip-10.0.1-py3.5.egg/EGG-INFO/entry_points.txt.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in venv/tensorflowTest/Lib/site-packages/pip-10.0.1-py3.5.egg/EGG-INFO/requires.txt.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in venv/tensorflowTest/Lib/site-packages/pip-10.0.1-py3.5.egg/EGG-INFO/top_level.txt.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in venv/tensorflowTest/Lib/site-packages/pip-10.0.1-py3.5.egg/pip/_vendor/certifi/cacert.pem.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in venv/tensorflowTest/Lib/tcl8.6/init.tcl.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in venv/tensorflowTest/Scripts/activate.
The file will have its original line endings in your working directory

(6)执行提交

4@DESKTOP-BUCB38P MINGW64 /d/pygit (master)
$ git commit -m "Started project"
[master (root-commit) 650c47a] Started project
 395 files changed, 102246 insertions(+)
 create mode 100644 .idea/encodings.xml
 create mode 100644 .idea/misc.xml
 create mode 100644 .idea/modules.xml
 create mode 100644 .idea/pygit.iml
 create mode 100644 .idea/workspace.xml
 create mode 100644 hello.py
 create mode 100644 venv/tensorflowTest/Lib/site-packages/easy-install.pth
 create mode 100644 venv/tensorflowTest/Lib/site-packages/pip-10.0.1-py3.5.egg/EGG-INFO/PKG-INFO
 create mode 100644 venv/tensorflowTest/Lib/site-packages/pip-10.0.1-py3.5.egg/EGG-INFO/SOURCES.txt
 create mode 100644 venv/tensorflowTest/Lib/site-packages/pip-10.0.1-py3.5.egg/EGG-INFO/dependency_links.txt
 create mode 100644 venv/tensorflowTest/Lib/site-packages/pip-10.0.1-py3.5.egg/EGG-INFO/entry_points.txt
 create mode 100644 venv/tensorflowTest/Lib/site-packages/pip-10.0.1-py3.5.egg/EGG-INFO/not-zip-safe
 create mode 100644 venv/tensorflowTest/Lib/site-packages/pip-10.0.1-py3.5.egg/EGG-INFO/requires.txt

可以查看提交状态$ git log

6. 生成ssh key使得Git Hub与本地Git管理的仓库建立连接

(1)生成key 执行命令后三次回车
显示信息提醒了秘钥所在位置 ‘/c/Users/4/.ssh’

4@DESKTOP-BUCB38P MINGW64 /d/pygit (master)
$ ssh-keygen -t rsa -C "1461946376@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/4/.ssh/id_rsa):
Created directory '/c/Users/4/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/4/.ssh/id_rsa.
Your public key has been saved in /c/Users/4/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:UkXcWwaqw2DoXKkO+kJaT3CHG9EXia7vdzbm1Qoqbxk 1461946376@qq.com
The key's randomart image is:
+---[RSA 2048]----+
|     . ..=o...   |
|    ..o.o.... o  |
|    .+=.. .  +   |
|  .o++o+ .  .    |
|  .o+=. S        |
| o.o+  .E.   .   |
|+. o..   o. . .  |
|o.  . o +.=o .   |
| ..  ..=o=...    |
+----[SHA256]-----+

(2)进入到 '/c/Users/4/.ssh’目录下查看秘钥

4@DESKTOP-BUCB38P MINGW64 /d/pygit (master)
$ cd ~/.ssh/

4@DESKTOP-BUCB38P MINGW64 ~/.ssh
$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCx0RYJKzIbA74Iq08SYByudF8XGYq13NYtrAl7Z5/J/5hDsOA9L+IG3LwiDynuOelxew/HGUvCucBq2YJI9ZmK/rZLQLSsC+lSCNLX0xwJNwya3mlv5V6BWeaZbkuc5NZmviKM2trNhOde2yTuN0iwufimHzkweYY9gHEhmZqUhMB4uJUISBWGUq3J/RBwwaaaBk5o/A4h6MiB/xUj1VFCiiajiueQg9cXgLIip4LTwttKKgaD9zF7XJilInY5GhEwPQqGrBB6kGZRImobMNLxSItTJuL536PMNvdLLCbVw3OPG5ffspMBPRMzUYOSQYypXOWUnZFeMdQz9ePcZ7Sx 1461946376@qq.com

复制显示的整个秘钥信息
复制红框框此时可以召唤回GitHub网页啦~
在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述红框框就是刚刚复制的秘钥嗷~~点Add就OK啦~
回到mymygit下点击SSH,复制里面的内容
在这里插入图片描述回到Git Bush上远程提交

4@DESKTOP-BUCB38P MINGW64 /d/pygit (master)
$ git remote add origin git@github.com:ZanLore/mymygit.git

4@DESKTOP-BUCB38P MINGW64 /d/pygit (master)
$ git push origin master
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)? y
Please type 'yes' or 'no': yes
Warning: Permanently added 'github.com,13.250.177.223' (RSA) to the list of known hosts.
Enumerating objects: 434, done.
Counting objects: 100% (434/434), done.
Delta compression using up to 8 threads
Compressing objects: 100% (423/423), done.
Writing objects: 100% (434/434), 8.73 MiB | 459.00 KiB/s, done.
Total 434 (delta 64), reused 0 (delta 0)
remote: Resolving deltas: 100% (64/64), done.
To github.com:ZanLore/mymygit.git
 * [new branch]      master -> master

此时再回到Git Hub就会发现上传成功的文件
在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值