git 操作命令

142 阅读2分钟

souretree使用教程

www.jianshu.com/p/6b5ed581b…

git的使用

www.liaoxuefeng.com/wiki/896043…

安利插件

image.png

www.cnblogs.com/jimboi/p/82…

快速删除nodemoudule/方法

www.jianshu.com/p/13c2de829…

设置 git config --global user.name "Your Name"

git config --global user.email "email@example.com"

git config --global color.ui true 让Git显示颜色 .gitignore 编写 git config --global alias. order 为命令设置别名

基本操作

git init

git add

git reset HEAD

git commit -m

git checkout --

git rm

仓库状态

git status

git diff

git log

git reset --hard

git reflog

分支管理

git branch

git branch

git branch -d

git push origin :

git branch -D

git branch -m <old_branch_name> <new_branch_name>

git checkout

git checkout -b

git merge

git merge --no-ff -m

git stash

git stash list

git stash apply

git stash drop stash@{1}

这个1是指stash列表中第几个

git stash drop会直接默认删除第一个

git stash pop

git stash apply

当意外删除stash的时候,可以通过id 去找到丢失的数据blog.csdn.net/weixin_4438…

git rebase

分支命名规范

def 分支命名规范:点这里 bug或线上问题修复: hotfix/{bug介绍_发布日期} , 比如: hotfix/remove_matter_20200515 日常迭代: daily/{迭代版本号} ,比如:daily/1.2.1 迁移或者技术升级,重构等重大意义开发: major/{desc} , 比如: major/next_to_build_sacript 多人预发/多人日常开发,需要共用一套开发环境: 分支命名:merge/{日期} ,比如:merge/20200515 其他同学都向 merge 分支merge 代码 多人发布(同一个应用,同一天发布): 分支命名: publish/{日期} ,比如:publish/20200515 发布 publish 分支,回滚测试也是该分支

远程仓库

ssh-keygen -t rsa -C "youremail@example.com"

git remote add origin

可以添加多个远程仓库如git remote add rdmclin2 git@.... origin rdmclin2都是我们为远程仓库取的别名。

git remote set-url origin ,

git push origin

git clone

clone时可以指定深度,git clone git://xxoo --depth 1

git remote

git pull

git fetch

git branch --set-upstream

标签管理

git tag

git tag

git show

git tag

git tag -a -m

git tag -s -m

git tag -d

git push origin

git push origin --tags

git push origin :refs/tags/

参考资料 廖雪峰的git教程 cheetsheet git flow