git

Git 进阶命令

2016-08-19  本文已影响12人  煒weelion
git.png

改动添加到暂存器

git stash save

使用场景:切换分支时或者拉取远程代码时可以将本地的所有改动暂存到 stash 中

读出暂存器内容

git stash pop

创建分支

git branch <branch-name>

删除分支

git branch -d <branch-name>

删除远程分支

git push <remote-name> :<branch-name>

切换分支

git checkout <branch-name>

合并分支

git merge <branch-name>

当前分支合并<branch-name>

添加 tag

git tag <tag-name>

删除本地 tag

git tag -d  <tag-name>

提交 tag 到远程仓库

git push origin <tag-name>

删除远程 tag

git push origin :<tag-name>

代码切到指定 tag

git checkout <tag-name>

查看版本操作记录

git reflog

添加子项目

git submodule add <repo-url> <path>

如:git submodule add git@github.com:weelion/test.git vendor

初始化子项目

git submodule update --init --recursive 

删除子项目

git submodule rm <path>

提取任意几个提交

git cherry-pick <commit-hash> <commit-hash> …
上一篇 下一篇

猜你喜欢

热点阅读