git 基础
配置信息
git config --list
查询配置文件的内容git config --global user.name "lango"
设置用户名git config --global user.email yaowenlang1989@163.com
设置用户邮箱git config user.name
查询现在用的用户名git config user.email
查询现在用的邮箱地址.gitigore
忽略文件配置git help 三种方法
git help <verb>
git <verb> --help
man git-<verb>
创建Git Repository
git init
在现有的工程目录创建用来管理当前项目git clone [url] [project name]
克隆现有的仓库五个区域
- “Stash” “WorkSpace” “Stage(Index)” “Repository” “Origin”
文件状态
- tracked
"unmodified" "modified" "stage"
- untracked
Git 存储方式
- 保存的是一系列不同时刻到快照
基本命令
git status [-s]
查看文件状态git diff
查看WorkSpace对比Index更新内容git diff --staged
查看Index对比Repository更新内容git log [-v][--pretty=oneline]
查看提交历史git add [file]
暂存file文件git commit [-m 'msg']
提交到Repositorygit commit -a
把所有tracked文件和Stage区文件一并提交git rm <file>
把文件从WorkSpace和Index删除git rm --cached <file>
只删除Index的文件git mv A B
把文件名称A该名成B名称git checkout <file>
文件从Index取到WorkSpace进行覆盖git checkout HEAD <file>
文件从Repository取到Index和WorkSpace进行覆盖git reset
Repository最新版本重置到Index远程仓库
git clone [url]
克隆一个仓库git remote [-v]
查看已经配置的远程仓库服务器git remote show [remote-name]
查看更多信息git remote add <shortname> <url>
链接的引用简写git fetch [remote-name]
从远程仓库获得数据,不会合并分支git push [remote-name][branch-name]
推送到远程仓库git pull
自动抓取然后合并远程分支到当前分支git remote rename
引用重命名git remote rm [shortname]
删除远程仓库标签
git tag [-l 'version']
列出已有到标签git tag v1.4 -m 'my version 1.4'
创建一个附注标签git show v1.4
显示附注标签v1.4信息git tag v1.4-lw
创建一个轻量标签git show v1.4-lw
显示轻量标签v1.4信息git tag -a v1.2 [SHA-1]
给历史版本打标签git push origin v1.5
标签共享到服务器git push origin --tags
一次推送多个标签Git 别名
$ git config --glovall alias.com checkout
把命令checkout改成co