安装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
'