工具-Git与GitHub-GitHub使用(99.5.3)

@

1.在github中添加公钥

首次使用git必须配置邮箱(邮箱和github一致)

git config --global user.name "xxx"
git config --global user.email [email protected]

在linux命令行或者win的git-bash中输入

ssh-keygen -t rsa -C "邮箱地址"

进入主目录下的.ssh文件,使用文本工具查看公钥复制此内容到github的设置中
公钥为id_rsa.pub
私钥为id_rsa
在这里插入图片描述

2.克隆项目

切换到要使用git的目录,使用ssh克隆

git clone [email protected]:BOTHSAVAGE/Test.git

在这里插入图片描述

3.在本地工作区新建分支,修改文件并提交

git checkout -b smart
git add .
git commit -m "first_commit"

4.推送到远程仓库

git push origin 分支名称
例:
git push origin smart

将本地分支跟踪远程分支

git branch --set-upstream-to=origin/远程分支名称 本地分支名称
例:
git branch --set-upstream-to=origin/smart smart

5.从远程分支上拉取代码

git pull orgin 分支名称
例:
git pull orgin smart

在这里插入图片描述

关于作者

个人博客网站
个人GitHub地址
个人公众号:
在这里插入图片描述

猜你喜欢

转载自www.cnblogs.com/simon-idea/p/11438532.html