Git基础命令

建Git仓库

场景一:把已有的项目代码纳入Git管理

cd <dir>
git init

场景二:新建的项目直接用Git管理

cd <dir>

git init your_project
# 会在当前路径下创建和县哪个木名称同名的文件夹

cd your_project

案例演示

准备项目文件

# 下载及解压项目代码文件
curl -o /tmp/0-material.zip https://git201901.github.io/github_pages_learning/docs/0-material.zip
unzip /tmp/0-material.zip -d /tmp

# 准备项目文件夹
mkdir /wills
cd /wills

初始化项目

添加文件至项目

修改文件

重命名文件

通过 git log 查看版本演变历史

查看最近2条历史记录

查看简洁版信息

查看所有分支的版本历史

Last updated