image.png
虽然每天都在用 Git 命令, 但是偶尔会出现某个不常用的命令记不起来, 好尴尬呀这次将 Git 命令再做一次总结
branch 分支
git branch 查看所有分支
image.png
git branch xx 创建分支
image.png
git checkout xx 切换分支
image.png
git branch -a 查看本地和远程所有分支
image.png
远程仓库
git push origin 分支名: 分支名 推送本地分支名到远程
image.png
git fetch origin 分支名: 分支名 拉取远程分支
git branch -r 查看远程分支
image.png
git branch -d 分支名 删除本地分支
image.png
git push origin --delete 分支名 删除远程分支
image.png
提交代码
git status 查看本地代码状态
image.png
git add file-name 添加某个文件
git add . 添加所有文件到暂缓区
git commit -a -m 'xxx' 提交代码备注 xxx
git push origin 分支名 推送代码到远程分支
image.png
Git Tag
添加注解, 比如产品发布一个版本打一个 tag
git tag -a tag-name -m "xxx" 创建 tag
image.png
git push origin tag-name 推送 tag 到远程
image.png
git show tag-name 查看某个 tag 标记内容
image.png
git checkout tag-name 切换 tag
git tag -d tag-name 删除本地 tag
image.png
其他操作
git stash 保存没有提交的修改
git merge branch-name 合并 branch-name 代码到当前分支
git log 查看各次提交信息
image.png
来源: http://www.jianshu.com/p/433f948ea25c