您的位置:首页 > 编程语言

ubuntu下使用git和github

2018-02-03 18:35 369 查看

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 address@xxx.com' -t rsa


公钥默认地址为 ~/.ssh/id_rsa.pub

五、上传公钥

在github的界面中 选择右上角的图标的Settings,然后选择SSH and GPG Keys,选择New SSH Key。



Title可以随便命名,Key的内容拷贝自~/.ssh/id_rsa.pub 中的内容.

使用ssh -v git@github.com进行测试。看到下面的信息表示验证成功。





六、创建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


参考资料:

如何在ubuntu下使用Github?

git和github在ubuntu下的使用
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: