注册github账号
在github的官网上注册一个账号 github。
注册以后我们就有自己的账号和密码了,下载git bash ,安装好了以后,按照以下步骤来:
mkdir hhh (项目名)
cd hhh
git init
touch README.md
git add README.md
git config --global user.name [username]
git config --global user.email [email]
git remote add origin https://github.com/你的用户名/hhh
创建分支
Git branch hh 创建分支 Git checkout hh 转换分支 Git push origin hh push到远程仓库
合并分支
Git checkout hh
Git merge hx
Git push origin hh
删除分支
在本地删除一个分支:git branch -d 分支名 在github远程端删除一个分支:git push origin :分支名
使用ssh-add添加密钥
1.查看是否已经有了ssh密钥:cd ~/.ssh
如果没有密钥则显示空
2.生成密钥:
ssh-keygent-t rsa -C “hx1074216264@gmail.com”
会看到有密码提示,输入你的密码即可
3.添加密钥
ssh-add id_rsa.pub(密钥名)
输入之前的密码
4.在github上添加ssh密钥即id_rsa.pub 里面的公钥
在github你的仓库添加ssh文件
注意:如果在使用ssh-add的时候提示:
Could not open a connection to your authentication agent
需要手动开启ssh,如下:
eval `ssh-agent -s`