GIT架构
GIT的架构,可以分为几个部分:
- 本地工作区(working directory)
- 暂存区(stage area, 又称为索引区, index)
- 本地仓库(local repository)
- 远程仓库副本
- 远程仓库(remote repository)
.git
$ tree -L 1
.
├── branches
├── COMMIT_EDITMSG
├── config
├── description
├── FETCH_HEAD
├── gitk.cache
├── HEAD
├── hooks
├── index
├── info
├── logs
├── objects
├── ORIG_HEAD
├── packed-refs
└── refs
ssh环境配置
- git config –global user.name “lxg”
- git config –global user.email “lxg@gmail.com”
- ssh-keygen
- cd ~/.ssh
- cat ~/.ssh/id_rsa.pub
- copy to gerrit or gitlab or github
git tag
查看tag
- git tag
- git tag -ln
- git show v1.1.1
- git checkout v1.1.1
新增tag
- git add .
- git commit -m “”
- git tag -a v1.1.1 -m “”
- git push origin v1.1.1
删除tag
- git tag -d v1.1.1
- git push origin –delete tag v1.1.1
git merge
git merge –no-ff sunmi/l2_release
分支重命名
- git branch -m oldName newName
- git push –delete origin oldName
- git push origin newName
- git branch –set-upstream-to origin/newName
Git 仓库迁移
git clone –mirror https://github.com/xxxxxxx/oldProject.git cd oldProject.git git remote set-url –push origin https://github.com/xxxxxxx/newProject.git git push –mirror
大文件下载
- git config –global core.compression 0 关闭压缩
- git clone –depth 1 url 下载最近一次提交
- git fetch –unshallow 获取完整库
- git pull –all 获取状态
上边的方法只能拉取主分支,拉取其他分支的方法
- git remote set-branches origin ‘remote_branch_name’
- git fetch –depth 1 origin remote_branch_name
- git checkout remote_branch_name
- git fetch –unshallow
本地删除不存在的远程分支
git remote prune origin