clone:下载仓库
git clone @链接
checkout:切换版本
git checkout 切换
git checkout -b branch 新建分支
git checkout -- file 撤销更改
submodule
下载的工程带有submodule(来源)
当使用git clone下来的工程中带有submodule时,初始的时候,submodule的内容并不会自动下载下来的,此时,只需执行如下命令:
git submodule update --init --recursive
branch
列出当前所有的分支
git branch
git branch -r
git branch -a
创建并切换分支
git branch -b
查看各个分支最后一个提交对象的信息
git branch -v
blame
查看某个文件代码的修改历史
git blame 文件名
stash
缓存下
git stash
更新
git pull
重新应用缓存
git stash pop
rebase
使用git rebase 合并多个 commit
首先,rebase -i 指定不需要改变的 commit
git rebase -i commit_id
然后弹出的信息文件中,将需要被合并的commit的pick
改成squash
需要被执行的commit依然为pick
然后保存文件,退出
修改合并后的 commit 信息
dev分支更新:
git rebase dev
- 解决冲突
git add .
git rebase --continue
git push -f
reset 和 revert
reflog
查看历史改动信息
remote -v
查看远程仓库地址
.gitignore
添加 .gitignore 文件,添加需要忽略的文件或文件夹
* .json
# 忽略 build 目录
build/
更改文件大小限制
Settings -> Repository -> Push Rules -> Maximum file size (MB)
改成自己想要的大小即可