git

作者: Binge003 | 来源:发表于2019-06-30 23:01 被阅读0次

http://rogerdudler.github.io/git-guide/index.zh.html
https://git-scm.com/book/zh/v2
https://learngitbranching.js.org/
https://www.jianshu.com/p/072587b47515
https://github.com/bingeli/helloworld-git

基本操作

$ git clone <url> #克隆-网页端新建的远程git仓库, 到本地
$ git init #新建-本地git仓库, 在当前文件夹下
$ git add <filename> #添加-目标文件, 到待存区
$ git commit -m "<commit message>" #提交-待存区, 作为一个节点, 到本地HEAD
$ git push origin master #推送-本地master分支到别名为origin的远程仓库
$ git pull #拉取-远程仓库的最新版本, 以免冲突

网页新建

$ git clone <url>
$ git pull
$ git add <filename>
$ git commit -m "本次提交的描述"
$ git push origin master

本地新建

$ git init
$ git remote add origin <url>
$ git pull
$ git add <filename>
$ git commit -m "本次提交的描述"
$ git push origin master

分支

$ git checkout -b <branch> #新建分支
$ git checkout -b <local branch> <remote branch> #checkout远程分支

撤销前一次本地提交

$ git rebase -i HEAD~2 #交互式编辑文本, 表示要修改前n个提交, 选edit
修改代码
$ git rebase --continue #保存修改

https://git-scm.com/book/zh/v2/Git-工具-重写历史

commit message格式参考

feat: 新功能 (feature)
fix: 修补bug
docs: 文档 (documentation)
style: 格式 (不影响代码运行的变动)
refactor: 重构 (即不是新增功能,也不是修改bug的代码变动)
test: 增加测试
chore: 构建过程或辅助工具的变动

https://segmentfault.com/a/1190000009048911

相关文章

网友评论

    本文标题:git

    本文链接:https://www.haomeiwen.com/subject/vbslgftx.html