GIT 命令 创建git仓库 本地仓库 远程仓库 分支管理

[TOC]

操作 命令
新建 git init
克隆 git clone [仓库url]

本地仓库

操作 命令
放入暂存区 git add [*|.file]
暂存区提交 git commit
查看提交记录 git log
查看提交详细内容 git show [commit HASH]
回滚提交 git reset [commit HASH]
查看未暂存文件修改对比 git diff
查看当前文件和暂存文件对比 git diff --cached

远程仓库

操作 命令
查看 git remote
新建 git remote add [远程仓库名] [远程仓库url]
重命名 git remote rename [远程仓库名] [新名称
删除 git remote rm [远程仓库名]
拉取 git fetch [远程仓库名] [远程分支]:[本地分支]
推送 git push [远程仓库名] [远程分支]:[本地分支]
强制推送 git push -f [远程仓库名] [远程分支]:[本地分支]

分支管理

操作 命令 tip
新建 git branch [分支名]
切换 git checkout [分支名]
合并 git merge [分支名] 合并到当前分支
删除 git branch -d [分支名] -D 强制删除

...待续