Git 使用教程

windows下使用git的方法

目录

@[toc]

一、准备工作

二、在github上的配置

1、新建一个仓库名

  • 仓库名字必须是: username.github.io ,其中username是你的用户名;
    github用户名

    2、新建一个工程

    在这里插入图片描述

3、配置SSH key(=>Settings)

第1步: Git 中 SSH key 生成步骤
(在windows下打开git bash,在控制台中输入以下命令。)

$ ssh-keygen -t rsa -C “youremail@example.com

在这里插入图片描述

在自己电脑中C:\Users\Administrator.ssh路径下生成下面两个文件:
id_rsa
id_rsa.pub

第2步:登录github。打开setting->SSH keys,点击右上角 New SSH key,把生成好的公钥id_rsa.pub放进 key输入框中y。
ssh图片
提交代码到git肯定要拥有你的github权限才可以,使用ssh key来解决本地和服务器的连接问题

4、测试下,增加个文件上传到仓库看看能否成功,在windows下git bash中操作

>…or create a new repository on the command line
echo "# read" >> test1   (把# read写入 test1 )
git init                   (初始化)
git add test1               (向仓库中添加README.md文件)
git commit -m "first commit" (提交备注)
git remote add origin https://github.com/411forget/test.git    (添加要提交到哪个仓库)
git push -u origin master    (从本地向远端推送提交的文件)

查看github中有没有推送的文件:
在这里插入图片描述

  1. 使用git克隆的方式,之后的更新可以通过 git pull 来快速更新使用git克隆的方式,之后的更新可以通过 git pull 来快速更新
    步骤如下:

    $ cd /e/WorkSpaces/hexo/

    $ git clone https://github.com/iissnan/hexo-theme-next.git themes/next

持续更新


-------------本文结束感谢您的阅读-------------