存储组织结构
- 使用
git add xxx
会将文件添加到暂存区,暂存区其实是一个抽象的概念,实际操作是往 .git 目录添加了blob 文件; git commit xxx
会生成 commit 文件而 commit 文件 借助一层或多层tree 文件 指向git add
添加的 blob 文件;git relog
能保存所有提交的记录,即使分支已经删除;- 分支只是一个指针,其实就是文件名为分支名,文件内容里保存了指向的 commit-id;
查看存储内容命令
cat .git/config # 当前代码仓库本地的配置文件
cat ~/.gitconfig # 全局配置文件
cat .git/description # 当前代码仓库的描述信息,一般都不会写
git cat-file -t commit-id # 查看 objects 的文件类型
git cat-file -p commit-id # 查看 objects 的文件内容
git cat-file -s commit-id # 查看 objects 的文件大小
git ls-files # 列出当前暂存区的文件列表信息
git ls-files -s # 列出当前暂存区文件的详细信息
HEAD 相关说明
- head 指向当前活动的分支;
- head 总是指向最近一次的提交;
常用命令
-
git --help
-
git --version
-
clear
-
git status
-
git init
-
git config user.name “XXX”
-
git config user.email “XXX”
-
git config --global merge.tool bc
-
git config --global mergetool.bc.path “D:\XXX\xxx”
-
git config alias.logg “log --oneline --decorate --graph” // 别名
-
git add -A
-
git add .
-
git commit
-
git commit -m “update a file”
-
git commit cmd.txt -am “edit cmd.txt” //改动的文件
//GitHub
- git remote -v # 查看远程服务器地址和仓库名称
- git remote show origin # 查看远程服务器仓库状态
- git remote add origin git@ github:robbin/robbin_site.git # 添加远程仓库地址
- git remote set-url origin git@ github.com:robbin/robbin_site.git # 设置远程仓库地址(用于修改远程仓库地址)
- git remote rm # 删除远程仓库
- ssh -T git@github.com
- ssh -Tv git@github.com
- ssh-keygen -t rsa -C “yourmail@gmail.com”
- git log --oneline
- git log -1
- git log -2 -p
- gitk
- git log --oneline -graph
- git clone 443 错误 :
fatal: unable to access ‘https://XXXX’: Failed to connect to github.com port 443: Connection refused
- 需要设置代理
设置代理
-
git config --global https.proxy http://127.0.0.1:8888
-
git config --global https.proxy “http://127.0.0.1:8888”
-
git config --global https.proxy https://127.0.0.1:8888
-
git config --global http.proxy ‘socks5://127.0.0.1:8888’
-
git config --global https.proxy ‘socks5://127.0.0.1:8888’
取消代理设置
- git config --global --unset http.proxy
- git config --global --unset https.proxy
已有仓库
cd git_repo
git remote add origin https://gitee.com/dataw/vue-demo.git
git push -u origin master