Ubuntu下使用GitHub

安装Git

第一步:检查是否安装了git

在终端输入git,显示如下说明已经安装了,可以跳过第二步,直接配置Github

第二步:安装git

sudo add-apt-repository ppa:git-core/ppa 

sudo apt install git 

第三步:验证是否安装完成

在终端输入git或者git-version

配置GitHub

前提是已有github账号,如果尚未注册,点击https://github.com/注册一个账号

git config --global user.name "你的github用户名"

git config --global user.email "你的github邮箱地址"

开始使用GitHub

第一步:新建本地仓库

比如:在Documents文件夹下新建名为Mytest的本地仓库,先将位置切换到Ducument目录下

cd Documents

mkdir Mytest

第二步切换到Mytest目录下,初始化本地仓库Mytest

cd ~/Document/Mytest

git init

第三步:对本地仓库进行更改(任意修改)

比如,添加Readme文件

touch Readme

第四步:提交更改

git add Readme

git commit -m 'add readme file'

连接github仓库

git remote add origin https://github.com/你的github用户名/你的github仓库.git

git push origin master

clone github已有内容到本地仓库

git clone https://github.com/你的github用户名/github仓库名.git

更改clone过来的仓库

例如,添加一个新的文件

touch Readme_new

依然需要提交更改

git add Readme_new

git commit -m 'add new readme file'

发布了4 篇原创文章 · 获赞 0 · 访问量 107

猜你喜欢

转载自blog.csdn.net/l1079823816/article/details/99297329