分支
git branch dev
git branch
git branch -d dev
git branch -D dev
- 创建本地
branch-name
分支与远程origin/branch-name
分支的链接关系
git branch --set-upstream <branch-name> <origin/branch-name>
切换分支并更新工作区
git checkout dev
git checkout -b dev
git checkout -d dev
- 在本地创建和远程分支对应的分支,本地和远程分支的名称最好一致
git checkout -b <branch-name> <origin/branch-name>
git checkout <file>
合并分支
- 合并指定分支到当前分支,如果可能,Git会用
Fast forward
模式,但这种模式下,删除分支后,会丢掉分支信息
git merge dev
- 合并分支,并保留分支的提交记录
commit
(禁用Fast forward
)
git merge --no-ff -m "merge with no-ff" dev
储藏工作现场
git stash
git stash list
- 恢复工作区
stash@{0}
的修改,恢复后并不会删除stash@{0}
,需要手动删除
git stash apply stash@{0}
git stash drop stash@{0}
git stash pop stash@{0}
标签
git tag <tag_name>
git tag <tag_name> <commit_id>
git tag -d <tagname>
git tag -a <tag_name> -m "<descriptive text>"
git show <tag_name>
git push origin :refs/tags/<tagname>
git tag
git tag -s <tagname> -m "<descriptive text>"