初始化项目
$ git init
将文件加入版本控制
$ git add {fileName}
使用 ‘.’ 代替文件名可以非常方便的将目录下的所有文件加入版本控制。如果需要忽略掉一些文件和目录,在
.gitignore文件中添加它们的名称。
从版本控制中移除文件
$ git rm -r --cached {fileName}
添加远程仓库
$ git remote add {远程仓库名称} {远程仓库地址}
上述命令中的远程仓库名称可以自由指定,一般为 origin。
查看已经添加的远程仓库
$ git remote -v
删除已经添加的远程仓库
$ git remote rm {远程仓库名称}
提交修改
$ git commit '{Message}'
推送到远程仓库
$ git push -u origin master
.gitignore 文件配置
# 此为注释 – 将被 Git 忽略# 忽略所有 .png 结尾的文件*.png# 但 logo.png 除外!logo.png# 仅仅忽略项目根目录下的 TODO 文件,不包括 subdir/TODO/TODO# 忽略 build/ 目录下的所有文件build/# 忽略 doc/*.txt,但不包括其子文件夹下的 txt 文件doc/*.txt# 忽略 doc/ 目录及其子目录下所有 txt 文件doc/**/*.txt
