git基本操作
初始化一个仓库(repository)、开始或停止跟踪(track)文件、暂存(stage)或提交(commit)更改
如何配置 Git 来忽略指定的文件和文件模式、如何迅速而简单地撤销错误操作、如何浏览你的项目的历史版本以及不同提交(commits)之间的差异、如何向你的远程仓库推送(push)以及如何从你的远程仓库拉取(pull)文件
--初始化仓库
$ git init
--添加追踪文件到暂存区
$ git add
--提交更新
$ git commit
$ git commit -m
$ git commit -a -m
--克隆
$ git clone <url>
--检查当前文件状态
$ git status
--状态简览
$ git status -s
--查看尚未暂存的文件更新了哪些部分
$ git diff
--查看已暂存的将要添加到下次提交里的内容
$ git diff --staged
--查看已经暂存起来的变化
$ git diff --cached
--移除文件
$ git rm
--移动文件
$ git mv file_from file_to
查看提交历史
$ git log
--查看最近【数字】次的历史
$ git log -p -数字
--查看每次提交的简略统计信息
$ git log --stat
撤销操作
--撤消操作
$ git commit --amend
--取消暂存的文件
$ git reset HEAD <file>
--撤消对文件的修改
$ git checkout — <file> [这是个危险操作]
远程仓库
--查看远程仓库
$ git remote
--显示需要读写远程仓库使用的 Git 保存的简写与其对应的 URL
$ git remote -v
--添加远程仓库
$ git remote add <shortname> <url>
--从远程仓库中抓取与拉取
$ git fetch <shortname>
--拉取所有还没有的数据
$ git fetch <remote>
--推送到远程仓库
$ git push <remote> <branch分支>
--查看某个远程仓库
$ git remote show <remote>
--远程仓库的重命名
$ git remote rename <oldname> <newname>
--远程仓库移除
$ git remote remove <remote>
打标签
--列出标签
$ git tag
$ git tag -l "v 版本数字 *"
--创建标签
--附注标签
$ git tag -a <tagname> -m "描述"
--轻量标签
$ git tag <tagname>
--后期打标签
$ git tag -a <tagname> <部分校验和>
--共享标签
$ git push origin <tagname>
--删除标签
$ git tag -d <tagname>
--检出标签
$ git checkout 2.0.0
--
$ git checkout -b version2 v2.0.0
设置git别名
$ git config --global alias.co checkout
$ git config --global alias.br branch
$ git config --global alias.ci commit
$ git config --global alias.st status