git
2020-08-14 22:46:20 0 举报
AI智能生成
git
作者其他创作
大纲/内容
git config
设置名字和邮箱
git config user.name "Jon"<br>git config user.email "jon@test.com"
选项
--global
用户配置
--system
系统配置
--file
当前库配置
--unset
移除配置
git config --unset --global user.email
配置别名
git config --global alias.show-graph \<br>'log --graph --abbrev-commit --pretty=oneline'
基本概念
版本库 .git
对象库 object store
块 blob
文件的每一个版本表示为一个块
目录树 tree
代表目录
提交 commit
代表一次提交
标签 tag
给一个其他对象的别名
索引 index
描述整个版本库的目录结构,存在于本地<br>做文件名和blob的映射,目录名和tree的映射,tag和对象的映射
可寻址内容名称
git追踪内容
git命令
子命令
add<br>
选项
说明
添加文件到git库,git add .会把当前目录及子目录都添加到子目录
am<br>
选项
说明
Apply a series of patches from a mailbox
archive
说明
Create an archive of files from a named tree
选项
bisect <br>
说明
Use binary search to find the commit that introduced a bug
branch
说明
List, create, or delete branches
bundle
说明
Move objects and refs by archive<br>
checkout
说明<br>
Switch branches or restore working tree files
cherry-pick<br>
说明
Apply the changes introduced by some existing commits<br>
citool
说明
Graphical alternative to git-commit
clean
说明
Remove untracked files from the working tree<br>
clone<br>
说明
Clone a repository into a new directory<br>
commit
说明
提交变更到版本库
选项
--amend
--message
describe
说明
Give an object a human readable name based on an available ref<br>
diff
说明
Show changes between commits, commit and working tree, etc
fetch
说明
Download objects and refs from another repository<br>
format-patch
说明
Prepare patches for e-mail submission<br>
gc
说明
Cleanup unnecessary files and optimize the local repository
gitk
说明
The Git repository browser<br>
grep<br>
说明<br>
Print lines matching a pattern
gui<br>
说明
A portable graphical interface to Git
init
说明
Create an empty Git repository or reinitialize an existing one<br>
log<br>
说明
查看提交日志
merge
说明
Join two or more development histories together<br>
mv<br>
说明<br>
移动或重命名
notes
说明
Add or inspect object notes<br>
pull<br>
说明
Fetch from and integrate with another repository or a local branch
push
说明
Update remote refs along with associated objects<br>
range-diff
说明
Compare two commit ranges (e.g. two versions of a branch)<br>
rebase
说明
Reapply commits on top of another base tip<br>
reset
说明
Reset current HEAD to the specified state<br>
restore
说明
Restore working tree files<br>
revert
说明
Revert some existing commits<br>
rm
说明
Remove files from the working tree and from the index<br>
shortlog
说明
Summarize 'git log' output<br>
show<br>
说明
显示提交详情
stash
说明
Stash the changes in a dirty working directory away<br>
status
说明
Show the working tree status<br>
submodule
说明
Initialize, update or inspect submodules<br>
switch<br>
说明
Switch branches<br>
选项
--version
--git-dir
其他说明
选项可简写,例如:git commit --message="test" 等价于 git commit -m="test"
和子命令间的-可写可不写,例如:git commit 等价于 git-commit
可以通过双破折号来分离参数
配置文件
.git/config
优先级最高,可用--file选项修改
~/.gitconfig
用户配置,可用--global选项修改
/etc/gitconfig
系统配置,可用--system选项修改(需要有权限)
收藏
收藏
0 条评论
下一页