Git Pro 笔记--Git基础

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值