【windows下配置github 环境】

全局配置 git 账号

  • 全局配置 user.name and user.email ,输入如下命令:
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
  • C:\Users\username.gitconfig 中自动生成 user 项
[user]
	email = you@example.com
	name = Your Name

配置 SSH 密钥

  • 生成 SSH 密钥,与 GitHub 进行安全的通信:
ssh-keygen -t rsa -b 4096 -C "xxx@163.com"

-b 表示指定密钥长度,单位为位(bit) 而 SSH 密钥的长度,一般分为:
1024 bit:较低安全级别,不推荐
2048 bit:基本安全级别,通常推荐
3072 bit:较高安全级别
4096 bit:高安全级别,提供最大安全性

  • 生成公钥和私钥,一对密钥文件:

私钥:/C/Users/username/.ssh/id_rsa
公钥:/C/Users/username/.ssh/id_rsa.pub

  • 将公钥添加到 GitHub, 打开 GitHub -> Settings -> SSH and GPG keys -> New SSH key 将 id_rsa.pub 文件的内容粘贴进去。
    在这里插入图片描述

git commit message 模板

  • 全局使用这个commit message模板,输入如下命令:
git config --global commit.template ~/.git-commit-template
  • C:\Users\username.gitconfig 中自动生成 commit 项,git commit 的时候就会去配置文件中读取这一项指定的文件中的内容作为初始化信息填写到提交信息中
[commit]
	template = C:/Users/username/.git-commit-template
  • 在.gitconfig文件的同级目录下新建以 .git-commit-template 命名的文本文件,内容如下:
[description]:
[rootcause]:
[solution]:
[self check]:
1. build pass
2. xxx case pass
3. na
[issue/task id]:na
  • 提交代码时只输入 git commit 即可自动加载模版 message:
git commit

创建一个新 project

  • 在 github 上创建一个空仓库
    在这里插入图片描述
  • 新工程首次提交,在代码根目录下输入一下命令:
git init
git add .
git commit
git remote add origin https://github.com/xxxx/xxxx.git
git push -u origin master
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值