Git学习笔记

工作区(working area),暂存区(stage area),仓库区(repository)
仓库操作
git init
git add
git reset
git commit
git rm
git mv
git log
git clean

远程仓库
git clone
git remote
git fetch
git pull
git push
git push --set-upstream origin branch_name

分支
git checkout
git branch
git merge
git rebase
git checkout --track origin/branch_name 本地会新建一个分支会自动跟踪远程的同名分支

状态
git status
git stash

标签
git tag
git show

配置
git config
git help

Git原理

Git 是一个内容寻址文件系统,Git 的核心部分是一个简单的键值对数据库(key-value data store)。 你可以向 Git 仓库中插入任意类型的内容,它会返回一个唯一的键,通过该键可以在任意时刻再次取回该内容。由于 Git 最初是一套面向版本控制系统的工具集,而不是一个完整的、用户友好的版本控制系统,所以它还包含了一部分用于完成底层工作的命令。这部分命令一般被称作“底层(plumbing)”命令,而那些更友好的命令则被称作“高层(porcelain)”命令。

目录结构

-rw-r--r--    1 c0047111 UsersGrp        23 Feb 23 16:36 HEAD
drwxr-xr-x    1 c0047111 UsersGrp         0 Feb 23 16:36 branches
-rw-r--r--    1 c0047111 UsersGrp       112 Feb 23 16:36 config
-rw-r--r--    1 c0047111 UsersGrp        73 Feb 23 16:36 description
drwxr-xr-x    1 c0047111 UsersGrp         0 Feb 23 16:36 hooks
-rw-r--r--    1 c0047111 UsersGrp       209 Feb 24 10:15 index
drwxr-xr-x    1 c0047111 UsersGrp         0 Feb 23 16:36 info
drwxr-xr-x    1 c0047111 UsersGrp         0 Feb 24 10:17 objects
drwxr-xr-x    1 c0047111 UsersGrp         0 Feb 23 16:36 refs

底层命令

git hash-object
git cat-file
git write-tree
git read-tree

git update-ref
git symbolic-ref

git verify-pack
git gc

git fsck

git count-objects

内部对象

objects目录中

对象分类

tree object 目录对象
tree entry 数据对象
commit object 提交对象,有指向前一个提交的指针

对象格式

header =“type”#{content.length} ## type {blob,tree,commit}
content=“content”

数据存储

数据存在在KV的类型的数据库中,按照hash生成40位的文件名称,前两位目录,后38文件名称存储

分支引用

refs目录

分支

HEAD

refs/*

tag

轻量标签:直接指向commit对象

附注标签:tag object 指向提交对象

远程分支

refs/remotes

常用命令

start a working area (see also: git help tutorial)
clone Clone a repository into a new directory
init Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)
add Add file contents to the index
mv Move or rename a file, a directory, or a symlink
reset Reset current HEAD to the specified state
rm Remove files from the working tree and from the index

examine the history and state (see also: git help revisions)
bisect Use binary search to find the commit that introduced a bug
grep Print lines matching a pattern
log Show commit logs
show Show various types of objects
status Show the working tree status

grow, mark and tweak your common history
branch List, create, or delete branches
checkout Switch branches or restore working tree files
commit Record changes to the repository
diff Show changes between commits, commit and working tree, etc
merge Join two or more development histories together
rebase Reapply commits on top of another base tip
tag Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)
fetch Download objects and refs from another repository
pull Fetch from and integrate with another repository or a local branch
push Update remote refs along with associated objects

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值