版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_31456593/article/details/79248706
ubuntu下使用git和github
一、安装git
sudo apt-get install git
二、登录github账户
github网址:https://github.com/
没有github账户的请自行申请
三、设置本地git的用名和邮箱
git config --global user.name = "用户名或者用户ID"
git config --global user.email = "邮箱"
四、创建公钥
ssh-keygen -C 'you email [email protected]' -t rsa
公钥默认地址为 ~/.ssh/id_rsa.pub
五、上传公钥
在github的界面中 选择右上角的图标的Settings,然后选择SSH and GPG Keys,选择New SSH Key。
Title可以随便命名,Key的内容拷贝自~/.ssh/id_rsa.pub 中的内容.
使用ssh -v [email protected]进行测试。看到下面的信息表示验证成功。
六、创建github仓库
在github上创建一个仓库,假设,新建的仓库为test
在本地创建
echo "# test" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/czy36mengfei/test.git
git push -u origin master
七、pull和push操作
可以pull github上的文件,修改后再用push更新至github
git pull origin master
echo 'new test 2' >> ReadMe.md
git add ReadMe.md
git commit -m 'new readme'
git push origin master
八、查看当前git缓存空间状态
git status