Giter Site home page Giter Site logo

gitflow's Introduction

git flow 最佳实践

原文来自于:Git最佳实践

如果一个团队在使用Git时没有一些规范,那么将是一场难以醒来的噩梦!然而,规范固然重要,但更重要的是个人素质,在使用Git时需要自己养成良好的习惯。本文要从具体实践角度,尤其是在团队协作中,阐述如何去好好地应用 Git。这里以一个小型的flask应用作为演示。

1. 习惯养成

1.1 提交

如何去写一个提交信息,在具体开发工作中主要需要遵守的原则就是使每次提交都有质量,只要坚持做到以下几点就 OK 了:

  • 提交时的粒度是一个小功能点或者一个 bug fix,这样进行恢复等的操作时能够将误伤减到最低;
  • 用一句简练的话写在第一行,然后空一行稍微详细阐述该提交所增加或修改的地方;
  • 不要每提交一次就推送一次,多积攒几个提交后一次性推送,这样可以避免在进行一次提交后发现代码中还有小错误。

假如已经把代码提交了,对这次提交的内容进行检查时发现里面有个变量单词拼错了或者其他失误,只要还没有推送到远程,就有一个不被他人发觉你的疏忽的补救方法——首先,把失误修正之后提交,可以用与上次提交同样的信息。
git graph 然后,终端中执行命令 git rebase -i SHA,其中 SHA 是上一次提交之前的那次提交的,在这里是3b22372。 git graph 最后,这样就将两次提交的节点合并成一个,甚至能够修改提交信息! git graph

1.2 推送

当自己一个人进行开发时,在功能完成之前不要急着创建远程分支。

1.3 拉取

请读张文钿所写的《使用 git rebase 避免無謂的 merge》

1.4 合并

在将其他分支的代码合并到当前分支时,如果那个分支是当前分支的父分支,为了保持图表的可读性和可追踪性,可以考虑用 git rebase 来代替 git merge;反过来或者不是父子关系的两个分支以及互相已经 git merge 过的分支,就不要采用 git rebase 了,避免出现重复的冲突和提交节点。

gitflow's People

Contributors

shawnzhang31 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.