git cookbook-最佳实践

git 最佳实践

总结一下日常工作中的git的使用实践

  • 使用场景:

    • 多人协同开发同一个项目模块
    • 需要解决冲突,越早解决冲突越好
    • 本地master分支最好经常pull,越频繁的把远程master分支merge到本地Master,越能减少冲突的出现
    • git的每次commit都是一个全量数据,svn每次提交都是一个增量数据
    • git 的每次commit都应该是一个有意义的可执行的全量代码,而不应该是一些fix bug的提交
    • 如果修改了代码还不想commit记录,用commit --amend修改commit记录.
    • 合并多个commit可以用git rebase -i
    • 慎用git rebase,最好避免使用
  • 开发流程:

    • 一般会分为master,dev,feature等环境,master专门用来线上发布,每次发布版本必须用master代码,所有人的代码都要提交到master
    • 根据需求or功能,本地创建相应分支,例如git branch -b feature/add-id,把本地分支推到远端同名分支,此时远端没有此同名分支,需要git push origin feature/add-id:feature/add-id,此时通过git branch -vv,可以观察到远端分支与本地分支并没有关联,因此需要git push --set-upstream origin feature/add-id,关联远端同名分支,此时完成分支创建并关联远端分支
    • 在向远端push代码之前,记得切换到本地master分支并且pull远端最新的master代码,在切换到开发分支,merge master代码,这样做的好处是在pr之后,不需要解决冲突就可以发布代码,一般来说未解决冲突的分支是不允许merge到master的
  • 上线流程

    • 发布上线之前,代码应该在线上环境经过验证,一般测试环境是线下
    • 灰度部署,根据服务器数量进行一定比例的灰度部署
    • 灰度期间,注意观察error,告警,服务器qps,tp90,99等指标,与同时间段未灰度的机器对比,与之前同时间段的集群对比
    • 出现问题,即使回滚到稳定包,一般稳定包是部署成功的上一个包对应的master代码
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Over 60 hands-on recipes to efficiently self-host your own Git repository using GitLab, About This Book, Get hands-on with day-to-day tasks to effectively manage and administer your repository with GitLabCovers advanced topics like GitLab continuous integration and LDAP integrationAuthored by a member of the GitLab core team, this Cookbook gives practical insights into installing and self-hosting your own GitLab and GitLab CI server, Who This Book Is For, This book is aimed at developers and devops that have a GitLab server running, and want to be sure they use it to its full potential. This book will also be useful for people looking for a great Git platform, and learn how to set it up successfully. Some system administrating experience on a UNIX-based system would be useful, but is not required., What You Will Learn, Install and maintain your GitLab instance Work with multiple users, create groups, and configure your project visibility Secure your code with the correct GitLab configuration Make the most of the built-in issue tracker, including merge requests Manage your projects through the GitLab API Set up webhooks and system hooks to receive notifications Manage your GitLab server using LDAP, In Detail, GitLab is a popular, open source Git hosting solution implemented by more than 50,000 organizations. This book has some carefully chosen recipes to help you decide on the type of GitLab installation that will fit your requirements. Along with covering some of the basic principles of Git, the book covers practical scenarios to show how you or your organization can effectively manage your proprietary code., You will learn how to manage multiple users, groups, and the permissions GitLab has for them. Updating your GitLab instance, creating backups, and restoring backups are a few of the important tasks described in detail to assist you in maintaining your GitLab server. Moreover, the GitLab API is extensively covered to guide you through the various operations to manage your project.
Title: Git Version Control Cookbook Author: Aske Olsson, Rasmus Voss Length: 273 pages Edition: 1 Language: English Publisher: Packt Publishing Publication Date: 2014-08-25 ISBN-10: 1782168451 ISBN-13: 9781782168454 90 hands-on recipes that will increase your productivity when using Git as a version control system Overview Filled with practical recipes that will teach you how to use the most advanced features of the Git system Improve your productivity by learning to work faster, more efficiently, and with more confidence Discover tips and tricks that will show you when and how to use the advanced features of Git In Detail Starting with the Git data model, you will learn how Git stores files and how it looks at commits. You will then learn how you can recover from mistakes; from committing on the wrong branch to recovering lost commits/files. Next, you will discover how you can force rebase on some branches and use regular Git merge on other branches. You will also learn how to extract information from the repository. As you progress through this book, you will learn how you can automate the usual Git processes by utilizing the hook system built into Git. The book also covers advanced repository management, including different options to rewrite the history of a Git repository. Finally, you will discover how you can work offline with Git, how to track what is going on behind the scenes, and how to use the stash for different purposes. What you will learn from this book Understand the Git data model and how you can navigate the database with simple commands Learn how you can recover lost commits/files Discover how you can force rebase on some branches and use regular Git merge on other branches Extract metadata from a Git repository Familiarize yourself with Git notes Discover how you can work offline with Git Debug with Git and use various techniques to find the faulty commit Approach This practical guide contains a wide variety of recipes, taking you through al
Paperback: 273 pages Publisher: Packt Publishing - ebooks Account (August 25, 2014) Language: English ISBN-10: 1782168451 ISBN-13: 978-1782168454 Key Features Filled with practical recipes that will teach you how to use the most advanced features of the Git system Improve your productivity by learning to work faster, more efficiently, and with more confidence Discover tips and tricks that will show you when and how to use the advanced features of Git Book Description Starting with the Git data model, you will learn how Git stores files and how it looks at commits. You will then learn how you can recover from mistakes; from committing on the wrong branch to recovering lost commits/files. Next, you will discover how you can force rebase on some branches and use regular Git merge on other branches. You will also learn how to extract information from the repository. As you progress through this book, you will learn how you can automate the usual Git processes by utilizing the hook system built into Git. The book also covers advanced repository management, including different options to rewrite the history of a Git repository. Finally, you will discover how you can work offline with Git, how to track what is going on behind the scenes, and how to use the stash for different purposes. What you will learn Understand the Git data model and how you can navigate the database with simple commands Learn how you can recover lost commits/files Discover how you can force rebase on some branches and use regular Git merge on other branches Extract metadata from a Git repository Familiarize yourself with Git notes Discover how you can work offline with Git Debug with Git and use various techniques to find the faulty commit
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值