{"id":3418,"date":"2019-09-30T07:43:37","date_gmt":"2019-09-30T07:43:37","guid":{"rendered":"https:\/\/waydev.co\/?p=3418"},"modified":"2026-11-10T13:44:27","modified_gmt":"2026-11-10T13:44:27","slug":"understanding-the-git-flow","status":"publish","type":"post","link":"https:\/\/waydev.co\/fr\/understanding-the-git-flow\/","title":{"rendered":"Understanding the Git flow"},"content":{"rendered":"Git flow is a lightweight, branch-based workflow that supports teams and projects where deployments are made regularly. This guide explains how and why Git flow works.\n<h3>Create a branch<\/h3>\nWhen you&#8217;re working on a project, you&#8217;re going to have a bunch of different features or ideas in progress at any given time \u2013 some of which are ready to go, and others which are not. Branching exists to help you manage this workflow.\n\nWhen you create a branch in your project, you&#8217;re creating an environment where you can try out new ideas. Changes you make on a branch don&#8217;t affect the\u00a0<code>master<\/code>\u00a0branch, so you&#8217;re free to experiment and commit changes, safe in the knowledge that your branch won&#8217;t be merged until it&#8217;s ready to be reviewed by someone you&#8217;re collaborating with.\n<h4>ProTip<\/h4>\nBranching is a core concept in Git, and the entire <a href=\"https:\/\/www.toptal.com\/gitflow\/enhanced-git-flow-explained\">Git flow<\/a> is based upon it. There&#8217;s only one rule: anything in the <code>master<\/code>\u00a0branch is always deployable.\n\nBecause of this, it&#8217;s extremely important that your new branch is created off of master when working on a feature or a fix. Your branch name should be descriptive (e.g.,\u00a0<code>refactor-authentication<\/code>,\u00a0<code>user-content-cache-key<\/code>,\u00a0<code>make-retina-avatars<\/code>), so that others can see what is being worked on.\n<h3>Add commits<\/h3>\nOnce your branch has been created, it&#8217;s time to start making changes. Whenever you add, edit, or delete a file, you&#8217;re making a commit, and adding them to your branch. This process of adding commits keeps track of your progress as you work on a feature branch.\n\nCommits also create a transparent history of your work that others can follow to understand what you&#8217;ve done and why. Each commit has an associated commit message, which is a description explaining why a particular change was made. Furthermore, each commit is considered a separate unit of change. This lets you roll back changes if a bug is found, or if you decide to head in a different direction.\n<h4>ProTip<\/h4>\nCommit messages are important, especially since Git tracks your changes and then displays them as commits once they&#8217;re pushed to the server. By writing clear commit messages, you can make it easier for other people to follow along and provide feedback.\n<h3>Open a Pull Request<\/h3>\nPull Requests initiate discussion about your commits. Because they&#8217;re tightly integrated with the underlying Git repository, anyone can see exactly what changes would be merged if they accept your request.\n\nYou can open a Pull Request at any point during the development process: when you have little or no code but want to share some screenshots or general ideas, when you&#8217;re stuck and need help or advice, or when you&#8217;re ready for someone to review your work. By using Git&#8217;s @mention system in your Pull Request message, you can ask for feedback from specific people or teams, whether they&#8217;re down the hall or ten time zones away.\n<h4>ProTip<\/h4>\nPull Requests are useful for contributing to open source projects and for managing changes to shared repositories. If you&#8217;re using a Fork &amp; Pull Model, Pull Requests provide a way to notify project maintainers about the changes you&#8217;d like them to consider. If you&#8217;re using a Shared Repository Model, Pull Requests help start code review and conversation about proposed changes before they&#8217;re merged into the master branch.\n<h3>Discuss and review your code<\/h3>\nOnce a Pull Request has been opened, the person or team reviewing your changes may have questions or comments. Perhaps the coding style doesn&#8217;t match project guidelines, the change is missing unit tests, or maybe everything looks great and props are in order. Pull Requests are designed to encourage and capture this type of conversation.\n\nYou can also continue to push to your branch in light of discussion and feedback about your commits. If someone comments that you forgot to do something or if there is a bug in the code, you can fix it in your branch and push up the change. Git will show your new commits and any additional feedback you may receive in the unified Pull Request view.\n<h4>ProTip<\/h4>\nPull Request comments are written in Markdown, so you can embed images and emoji, use pre-formatted text blocks, and other lightweight formatting.\n<h3>Deploy<\/h3>\nWith Git, you can deploy from a branch for final testing in production before merging to master.\n\nOnce your pull request has been reviewed and the branch passes your tests, you can deploy your changes to verify them in production. If your branch causes issues, you can roll it back by deploying the existing master into production.\n<h3>Merge<\/h3>\nNow that your changes have been verified in production, it is time to merge your code into the master branch.\n\nOnce merged, Pull Requests preserve a record of the historical changes to your code. Because they&#8217;re searchable, they let anyone go back in time to understand why and how a decision was made.\n<h4>ProTip<\/h4>\nBy incorporating certain keywords into the text of your Pull Request, you can associate issues with code. When your Pull Request is merged, the related issues are also closed. For example, entering the phrase\u00a0<code>Closes #32<\/code>\u00a0would close issue number 32 in the repository.\n<h3>What\u2019s a version control system?<\/h3>\nA version control system, or VCS, tracks the history of changes as people and teams collaborate on projects together. As the project evolves, teams can run tests, fix bugs, and contribute new code with the confidence that any version can be recovered at any time. Developers can review project history to find out:\n<ul>\n \t<li>Which changes were made?<\/li>\n \t<li>Who made the changes?<\/li>\n \t<li>When were the changes made?<\/li>\n \t<li>Why were changes needed?<\/li>\n<\/ul>\n<h3>What\u2019s a distributed version control system?<\/h3>\nGit is an example of a distributed version control system (DVCS) commonly used for open source and commercial software development. DVCSs allow full access to every file, branch, and iteration of a project, and allows every user access to a full and self-contained history of all changes. Unlike once popular centralized version control systems, DVCSs like Git don\u2019t need a constant connection to a central repository. Developers can work anywhere and collaborate asynchronously from any time zone.\n\nWithout version control, team members are subject to redundant tasks, slower timelines, and multiple copies of a single project. To eliminate unnecessary work, Git and other VCSs give each contributor a unified and consistent view of a project, surfacing work that\u2019s already in progress. Seeing a transparent history of changes, who made them, and how they contribute to the development of a project helps team members stay aligned while working independently.\n<h3>Why Git?<\/h3>\nAccording to the latest\u00a0<a href=\"https:\/\/insights.stackoverflow.com\/survey\/2017#technology\">Stack Overflow developer survey<\/a>, more than 70 percent of developers use Git, making it the most-used VCS in the world. Git is commonly used for both open source and commercial software development,\u00a0<strong>with significant benefits<\/strong>\u00a0for individuals, teams and businesses.\n<ul>\n \t<li>Git lets developers see the entire timeline of their changes, decisions, and progression of any project in one place. From the moment they access the history of a project, the developer has all the context they need to understand it and start contributing.<\/li>\n \t<li>Developers work in every time zone. With a DVCS like Git, collaboration can happen any time while maintaining source code integrity. Using branches, developers can safely propose changes to production code.<\/li>\n \t<li>Businesses using Git can break down communication barriers between teams and keep them focused on doing their best work. Plus, Git makes it possible to align experts across a business to collaborate on major projects.<\/li>\n<\/ul>\n<h3>What\u2019s a repository?<\/h3>\nA\u00a0<em>repository<\/em>, or\u00a0<a href=\"https:\/\/git-scm.com\/\">Git project<\/a>, encompasses the entire collection of files and folders associated with a project, along with each file\u2019s revision history. The file history appears as snapshots in time called\u00a0<em>commits<\/em>, and the commits exist as a linked-list relationship, and can be organized into multiple lines of development called\u00a0<em>branches<\/em>. Because Git is a DVCS, repositories are self-contained units and anyone who owns a copy of the repository can access the entire codebase and its history. Using the command line or other ease-of-use interfaces, a git repository also allows for: interaction with the history, cloning, creating branches, committing, merging, comparing changes across versions of code, and more.\n\nWorking in repositories keeps development projects organized and protected. Developers are encouraged to fix bugs, or create fresh features, without fear of derailing mainline development efforts. Git facilitates this through the use of topic branches: lightweight pointers to commits in history that can be easily created and deprecated when no longer needed.\n\nThrough platforms like GitHub, Git also provides more opportunities for project transparency and collaboration. Public repositories help teams work together to build the best possible final product.\n<h3>Basic Git commands<\/h3>\nTo use Git, developers use specific commands to copy, create, change, and combine code. These commands can be executed directly from the command line or by using an application like\u00a0<a href=\"https:\/\/desktop.github.com\/\">GitHub Desktop<\/a>\u00a0or Git Kraken. Here are some common commands for using Git:\n<ul>\n \t<li><code class=\"highlighter-rouge\">git init<\/code>\u00a0initializes a brand new Git repository and begins tracking an existing directory. It adds a hidden subfolder within the existing directory that houses the internal data structure required for version control.<\/li>\n \t<li><code class=\"highlighter-rouge\">git clone<\/code>\u00a0creates a local copy of a project that already exists remotely. The clone includes all the project\u2019s files, history, and branches.<\/li>\n \t<li><code class=\"highlighter-rouge\">git add<\/code>\u00a0stages a change. Git tracks changes to a developer\u2019s codebase, but it\u2019s necessary to stage and take a snapshot of the changes to include them in the project\u2019s history. This command performs staging, the first part of that two-step process. Any changes that are staged will become a part of the next snapshot and a part of the project\u2019s history. Staging and committing separately gives developers complete control over the history of their project without changing how they code and work.<\/li>\n \t<li><code class=\"highlighter-rouge\">git commit<\/code>\u00a0saves the snapshot to the project history and completes the change-tracking process. In short, a commit functions like taking a photo. Anything that\u2019s been staged with\u00a0<code class=\"highlighter-rouge\">git add<\/code>\u00a0will become a part of the snapshot with\u00a0<code class=\"highlighter-rouge\">git commit<\/code>.<\/li>\n \t<li><code class=\"highlighter-rouge\">git status<\/code>\u00a0shows the status of changes as untracked, modified, or staged.<\/li>\n \t<li><code class=\"highlighter-rouge\">git branch<\/code>\u00a0shows the branches being worked on locally.<\/li>\n \t<li><code class=\"highlighter-rouge\">git merge<\/code>\u00a0merges lines of development together. This command is typically used to combine changes made on two distinct branches. For example, a developer would merge when they want to combine changes from a feature branch into the master branch for deployment.<\/li>\n \t<li><code class=\"highlighter-rouge\">git pull<\/code>\u00a0updates the local line of development with updates from its remote counterpart. Developers use this command if a teammate has made commits to a branch on a remote, and they would like to reflect those changes in their local environment.<\/li>\n \t<li><code class=\"highlighter-rouge\">git push<\/code>\u00a0updates the remote repository with any commits made locally to a branch.<\/li>\n<\/ul>\nLearn more from\u00a0<a href=\"https:\/\/git-scm.com\/docs\">a full reference guide to Git commands<\/a>.\n<h4>Explore more Git commands<\/h4>\nFor a detailed look at Git practices, the videos below show how to get the most out of some Git commands.\n<ul>\n \t<li><a href=\"https:\/\/www.youtube.com\/watch?v=rBbbOouhI-s&amp;index=2&amp;list=PLg7s6cbtAD17Gw5u8644bgKhgRLiJXdX4\">Working locally<\/a><\/li>\n \t<li><a href=\"https:\/\/www.youtube.com\/watch?v=SxmveNrZb5k&amp;list=PLg7s6cbtAD17Gw5u8644bgKhgRLiJXdX4&amp;index=3\"><code class=\"highlighter-rouge\">git status<\/code><\/a><\/li>\n \t<li><a href=\"https:\/\/www.youtube.com\/watch?v=Vb0Ghkkc2hk&amp;index=4&amp;list=PLg7s6cbtAD17Gw5u8644bgKhgRLiJXdX4\">Two-step commits<\/a><\/li>\n \t<li><a href=\"https:\/\/www.youtube.com\/watch?v=-uQHV9GOA0w&amp;index=5&amp;list=PLg7s6cbtAD17Gw5u8644bgKhgRLiJXdX4\"><code class=\"highlighter-rouge\">git pull<\/code>\u00a0et\u00a0<code class=\"highlighter-rouge\">git push<\/code><\/a><\/li>\n<\/ul>\nSign up now for #1 <a href=\"https:\/\/waydev.co\/fr\/\">Engineering Intelligence for DORA Metrics platform<\/a> for Engineering Productivity and if you want to find out more about how Waydev can help you, <a href=\"https:\/\/waydev.co\/fr\/demo\/\" target=\"_blank\" rel=\"noreferrer noopener\">schedule a demo.<\/a>\n\n<!-- \/wp:post-content --> <!-- wp:image {\"id\":11488,\"width\":428,\"height\":65,\"sizeSlug\":\"full\",\"linkDestination\":\"custom\"} -->\n<figure class=\"wp-block-image size-full is-resized\"><a href=\"\/fr\/demo\/\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" class=\"wp-image-11488\" src=\"https:\/\/waydev.co\/wp-content\/uploads\/2021\/09\/CTA-1-1.png\" alt=\"Demo\" width=\"428\" height=\"65\" srcset=\"https:\/\/waydev.co\/wp-content\/uploads\/2021\/09\/CTA-1-1.png 428w, https:\/\/waydev.co\/wp-content\/uploads\/2021\/09\/CTA-1-1-300x46.png 300w\" sizes=\"(max-width: 428px) 100vw, 428px\" \/><\/a><\/figure>\n<!-- \/wp:image -->","protected":false},"excerpt":{"rendered":"<p>Git flow is a lightweight, branch-based workflow that supports teams and projects where deployments are made regularly. This guide explains how and why Git flow works. Create a branch When you&#8217;re working on a project, you&#8217;re going to have a bunch of different features or ideas in progress at any given time \u2013 some of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":4733,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"content-type":"","footnotes":""},"categories":[30],"tags":[],"fgroups":[],"class_list":["post-3418","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-engineering-productivity"],"acf":[],"_links":{"self":[{"href":"https:\/\/waydev.co\/fr\/wp-json\/wp\/v2\/posts\/3418","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/waydev.co\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/waydev.co\/fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/waydev.co\/fr\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/waydev.co\/fr\/wp-json\/wp\/v2\/comments?post=3418"}],"version-history":[{"count":2,"href":"https:\/\/waydev.co\/fr\/wp-json\/wp\/v2\/posts\/3418\/revisions"}],"predecessor-version":[{"id":25399,"href":"https:\/\/waydev.co\/fr\/wp-json\/wp\/v2\/posts\/3418\/revisions\/25399"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/waydev.co\/fr\/wp-json\/wp\/v2\/media\/4733"}],"wp:attachment":[{"href":"https:\/\/waydev.co\/fr\/wp-json\/wp\/v2\/media?parent=3418"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/waydev.co\/fr\/wp-json\/wp\/v2\/categories?post=3418"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/waydev.co\/fr\/wp-json\/wp\/v2\/tags?post=3418"},{"taxonomy":"fgroups","embeddable":true,"href":"https:\/\/waydev.co\/fr\/wp-json\/wp\/v2\/fgroups?post=3418"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}