您的位置:首页 > 其它

Git Pro 笔记--Git基础

2015-12-24 15:01 357 查看

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']
提交到Repository

git 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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  git Git-Pro-笔记