Computer Science Radar


-- Repo*
|-- .git*
|          |-- hooks*
|          |-- info*
|          |-- logs*
|          |-- objects*
|          |-- refs*
|          |-- COMMIT_EDITMSG 
|          |-- config 
|          |-- description 
|          |-- HEAD 
|          |-- index 
|-- .gitignore

*: Folders 

HEAD^: previous commit

HEAD~<n>: last n commits

working area§

Git commands options description
clone Clone a repository into a new directory
init Create an empty Git repository or reinitialize an existing one

current change§

Git commands options description
add Add file contents to the index
mv Create an empty Git repository or reinitialize an existing one
restore Restore working tree files
rm Remove files from the working tree and from the index

history and state§

Git commands options description
diff Show changes between commits, commit and working tree
log Show commit logs
--grep 搜索关键字
show Show various types of objects
status Show the working tree status


Git commands options description
commit Record changes to the repository
-a, --all commit all changed files
-m, --message <message> commit message
--amend amend previous commit
reset [<commit>] Reset current HEAD to the specified state
--hard reset HEAD, index and working tree
--soft reset only HEAD
tag <tagname> [<head>] Create, list, delete or verify a tag object signed with GPG


Git commands options description
fetch [<repository>] 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


Git commands options description
branch List, create, or delete branches
checkout/gco <branch>
-b <branch> create and checkout a new branch
merge Join two or more development histories together
rebase [<upstream> [<branch>]] Reapply commits on top of another base tip
-i, --interactive let the user edit the list of commits to rebase


Git commands options
remote [-v |--verbose]
add <name> <url>
rename <old> <new>
remove <name>


Git commands options description
--global use global config file
--local use repository config file
-l, --list list all
-e, --edit open an editor


section key
user name, email
http sslverify
https sslverify
core bare
credential helper


Inspects, updates and manages submodules.

The first one works for git version 1.8.2 or above while the second one works for git version 1.7.3 or above.


git clone --recursive


git submodule update --init --recursive --depth=1


git submodule update --recursive --remote
git submodule update --recursive
git pull --recurse-submodules

bare repository§

普通仓库用来干活(working),bare 仓库用来共享(sharing)。

Git 提供了分布式版本管理的方案,多人协作仍然需要一个中心式仓库用来同步工作。比如 GitHub 上的仓库就是 bare 仓库。

Bare 仓库中没有 working tree,因此不能在 bare 仓库中进行修改和提交。对 Bare 仓库只能 pushclone

git init --bare
git config --bool core.bare true

# 类似 push,将变更 clone 到 bare-repo
git clone –bare <bare-repo>

# 如果想要 push 到一个普通仓库,这个仓库需要设置,以接受工作树的不一致
# push 后仓库只会改变 HEAD 指针,需要 git reset --hard 同步索引和工作树
git config receive.denyCurrentBranch ignore

Bare 仓库类似与普通仓库中的.git目录。

Bare 仓库通常使用.git作为目录名的后缀。

-- BareRepo.git*
|-- hooks*
|-- info*
|-- logs*
|-- objects*
|-- refs*
|-- config 
|-- description 
|-- HEAD 
|-- index 

*: Folders 


Mirror sites§

在码云上查看项目是否存在镜像,也可以在码云中导入 GitHub 账号 fork 的仓库。

Gitee - 基于 Git 的代码托管和研发协作平台

替换 clone 时的仓库地址。



  1. 允许局域网连接。
  2. 允许通过 Windows 防火墙。


sudo apt install proxychains

安装后编辑 /etc/proxychains.conf 文件,修改最后一行。

# add proxy here ...
# meanwile
# defaults set to "tor"
socks5 10808

在命令前添加 proxychains,如 proxychains git clone ...


.zshrc 或者 .bashrc 中加入如下两行:

alias setproxy="export ALL_PROXY=socks5://" 
alias unsetproxy="unset ALL_PROXY"

只对 http 协议生效,比如 curlwget 等,而对于走 SSH 协议的 git clone git@... 是无效的,也不可以使用 ping 来验证。

git clone§


git config --global http.proxy 'socks5://' 
git config --global https.proxy 'socks5://'


git log --graph --pretty=oneline --abbrev-commit
# --pretty=format:%s


ncurses-based text-mode interface for Git

sudo apt install tig


server certificate verification failed. CAfile: none CRLfile: none§

使用私人网站或镜像网站作为 Git 服务器时,证书不可信。

git config --global http.sslverify false
git config --global https.sslverify false



git config --global credential.helper store
vim ~/.git-credentials

old mode 100755 new mode 100644§

git config --global core.filemode false
git update-index --chmod=(+|-)x <path>


  1. Git教程 - 廖雪峰的官方网站 (
  2. 开始使用 Git - GitHub Docs
  3. Git Tutorials and Training | Atlassian Git Tutorial
  4. Bare Repositories in Git - GeeksforGeeks
  5. WSL使用本地代理和git clone加速 - No Visitor Website (