GitHub前期准备


###1. 初始设置

  • 设置姓名和邮箱

$ git config --global user.name "zhaojun"
$ git config --global user.email "zhaojunhhu@gmail.com"
  • 提高命令输出的可读性

$ git config --global color.ui auto
  • 查看Git配置

$ cat ~/.gitconfig
[filter "lfs"]
	clean = git-lfs clean %f
	smudge = git-lfs smudge %f
	required = true
[user]
	name = zhaojun
	email = zhaojunhhu@gmail.com
[color]
	ui = auto
[push]
	default = simple

###2. 设置SSH Key

  • GitHub上连接已有仓库时的认证,是通过使用SSH的公开密钥认证方式进行的。创建公开密钥认证所需的SSH Key,并将其添加至GitHub。

**id_rsa.**文件是私有密钥,**id_rsa.pub.**文件是公开密钥。

  • 查看公开密钥和私有密钥

  • 私人密钥与GitHub认证通信

###3. 公开代码

  • clone已有仓库

  • 编写代码

hello-world文件夹中添加index.phpprocess.php2个文件,由于这2个文件还没有添加至Git仓库,所以显示为Untracked files。

  • 提交

index.phpprocess.php提交至仓库,文件进入版本管理系统的控制。今后的更改管理都交由git进行。

通过git add命令将文件加入暂存区,再通过git commit命令提交。添加成功后,可以通过git log命令查看提交日志。

  • 进行push

通过push更新GitHub上的仓库。

Last updated

Was this helpful?