zl程序教程

您现在的位置是:首页 >  工具

当前栏目

github简单教程

GitHub教程 简单
2023-09-27 14:28:09 时间

1、注册一个账号,可以用国内的邮箱。以 abc@126.com 为例。

2、在github上新建一个仓库,名称就用test,假设github的用户名是:abc,则该仓库地址:https://github.com/abc/test

3、在本地生成 ssh 相关。首先生成 ssh密钥对:

1、生成密钥对。
sshkey -t rsa -b 4096 -C "abc@126.com"
2、将密钥添加到ssh-agent当中。
#在后台启动ssh-agent,系统回显pid
eval  "$(ssh-agent  -s)"
ssh-add ~/.ssh/your_name
3、复制公钥(test.pub)到github账户的设置选项中,然后保存。
4、测试。ssh -T git@github.com
5、把空仓库test拉到本地。git clone git@github.com:abc/test.git

4、在本地设置git的邮箱和账号

git config --global user.email "abc@126.com"
git config --global user.name "abc"

5、运行 git add .  ,将需要的文件全部添加到git库中。

6、提交。 git commit -m 'first commit' 

7、推送到github。 git push

8、备注,git会在每个仓库中添加一个 .git ,隐藏文件夹来保存git的信息和配置文件,仔细阅读会有很多收获。git的全局配置文件,在用户目录下的 .gitconfig 文件中。