常用
- git add . 提交到暂存区
- git commit -m "这里是信息" 提交代码到本地(不会弹出编辑器)
- git commit 提交代码到本地(会弹出编辑器输入提交信息)
- git commit --no-verify 提交绕过提交钩子 (-n / --no-verify)
- git push 推送远端
- git pull 拉取代码
- git pull origin
[b]从当前分支拉取远端 b 分支的代码
查看
- git branch 查看本地分支
- git branch -r 查看所有远程分支
- git branch -a 查看所有本地分支和远程分支
新建
- git checkout
[branch]切换分支 - git branch
[branch-name]新建一个分支,但依然停留在当前分支 - git checkout -b
[branch]新建一个分支,并切换到该分支 - git push --set-upstream origin release/1.0.0 推送分支 (release/1.0.0) 到远端
合并
- git checkout master 切换分支到 master
- git merge dev 合并dev分支到 master 上
- git push origin master 将代码推到远端 master 上
tag
- git tag 查看 tag
- git tag 1.0.0.pre-a1 打 tag(1.0.0.pre-a1)
- git push origin 1.0.0.pre-a1 推送 tag(1.0.0.pre-a1) 到远端
- git tag -d v0.1.2 本地删除 tag
- git push origin :refs/tags/v0.1.2 远端删除 tag
更新tag
- git tag -l | xargs git tag -d
- git fetch origin --prune
- git fetch origin --tags
sourcetree 软件
- git remote update origin --prune sourcetree 更新远程分支
git vim 编辑器
如果要输入解释的话就需要:
-
按键盘字母 i 进入insert模式
-
修改最上面那行黄色合并信息,可以不修改
-
按键盘左上角"Esc"
-
输入":wq",注意是冒号+wq,按回车键即可