init
初始化
git init
status
查看状态
git status
reflog
查看本地仓库版本信息
git reflog
add
提交所有文件至缓存区
git add .
rm
删除暂存区文件
git rm -r -f --cached <文件名>
删除暂存区所有文件
git rm -r --cached .
commit
提交至本地库
git commit
提交至本地库带提交信息
git commit -m "提交信息"
reset
回滚版本,更新工作区和缓存区
#更新工作区和缓存区
git reset --hard <commit id>
回滚版本,只更新索引
#只更新索引
git reset --soft <commit id>
branch
添加分支
git branch <分支名>
查看分支
git branch
删除分支
git branch --delete <分支名>
checkout
切换分支
git checkout <分支名>
merge
合并分支,将指定的分支合并到当前分支
git merge <分支名>
合并分支,并且重新提交
git merge --squash {{分支名}}
cherry-pick
将指定版本的变更合并到到当前分支
git cherry-pick -e <commit id>
clone
克隆远程库
git clone <远程库连接>
克隆指定分支
git clone -b <分支名> <远程库连接>
remote
配置远程库连接地址
git remote add <远程库别名> <远程库地址>
查看已配置的远程仓库地址
git remote
删除远程仓库配置
git remote rm <远程库别名>
更新远程库信息
git remote update ${远程库别名} --prune
push
推送至远程库,远程分支可以不写,则默认使用本地分支名一致进行推送
git plush <远程库地址别名> <本地分支> [远程分支]
删除远程分支
git push <远程库别名> --delete <远程分支名>
推送所有版本信息
git push <远程地址别名> --tags
推送单个版本
git push <远程地址别名> <版本号>
删除远程版本
git push <远程地址别名> --delete <版本号>
pull
从远程库拉取,从远程分支拉取到当前本地库做指的分支
git pull <远程库地址别名> <远程分支>
fetch
更新远程仓库版本,不合并本地分支
git fetch
tag
查看所有版本
git tag
提交版本信息
不填commit id默认当前节点
git tag -a <版本号> [commit id] -m "版本信息"
删除版本
git tag -d <版本号>
rebase
变更当前分支的基线于指定分支
git rebase <分支名>
继续提交
git rebase --continue
将多个commit合并
commit id:将所指定的提交上的所有提交合并
git rebase -i <commit id>
config
设置拉取不转换换行符
git config --global core.autocrlf false
git config --global core.safecrlf true
设置不用重复输入密码
git config --global credential.helper store
设置代理
git config –-global http.proxy ${http}
git config –-global http.proxy ${http}
log
查看历史提交
–oneline:单行显示
–graph:显示走线
–date-order:按照日期排序
–all:查看所有分支或者输入指定分支查看指定分支
–reverse:正序排列
git log [--oneline] [--graph] [--date-order] [--all]|[分支名] [--reverse]
忽略文件
文件名:.gitignore
.git
.idea
.gitignore
target
参数
–allow-unrelated-histories:强制合并