├── .gitignore ├── README.md ├── feature1.php └── images └── initialize.png /.gitignore: -------------------------------------------------------------------------------- 1 | .idea -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Git Flow - Why and How to use: 2 | GitFlow is a collection of Git commands to define a strict branching model designed around the project release for Vincent Driessen's [branching model](http://nvie.com/git-model "original blog post"). 3 | 4 | Gitflow is really just an abstract idea of a Git workflow. This means it dictates what kind of branches to set up and how to merge them together. The git-flow toolset is an actual command line tool that has an installation process.Git-flow extension is a wrapper around Git. 5 | 6 | ## Why should use git flow: 7 | 8 | - GitFlow is a collection of Git commands to provide many repository operations with just single command. 9 | - It was developed to manage the branching mechanism with a standardised approach when developing features, 10 | handling releases and managing hotfixes. 11 | - Using multiple separate branches in Git will provide flexibility but gets complex. This is easy in gitflow. 12 | - It makes developer speed up the process with familiar branch structure. 13 | - Switching branches is easy. 14 | - Keep repository & process clean and tidy. 15 | 16 | ## Installation: 17 | 18 | ### Setup 19 | You need a working git installation as prerequisite. Git flow works on macOS, Linux and Windows 20 | 21 | #### macOS 22 | 23 | Homebrew 24 | 25 | ``` $ brew install git-flow-avh ``` 26 | 27 | Macports 28 | 29 | ``` $ port install git-flow-avh ``` 30 | 31 | #### Linux (Debian) 32 | 33 | ``` $ apt-get install git-flow ``` 34 | 35 | #### Linux (Fedora) 36 | 37 | ``` $ sudo yum install gitflow ``` 38 | 39 | 40 | #### Windows (Cygwin) 41 | 42 | ```$ wget -q -O - --no-check-certificate https://raw.github.com/petervanderdoes/gitflow-avh/develop/contrib/gitflow-installer.sh install stable | bash ``` 43 | 44 | ### Getting started 45 | Git flow needs to be initialized in order to customize your project setup. 46 | 47 | #### Initialize 48 | After installing git-flow you can use it in your project by executing git flow init. 49 | 50 | ``` $ git flow init ``` 51 | 52 | The git flow init command is an extension of the default git init command and doesn't change anything in your repository other than creating branches for you. 53 | You'll have to answer a few questions regarding the naming conventions for your branches. 54 | It's recommended to use the default values. 55 | 56 | ![alt text](images/initialize.png) 57 | 58 | 59 | ### How it works 60 | 61 | Instead of a single master branch, this workflow uses two branches to record the history of the project. The master branch stores the official release history, and the develop branch serves as an integration 62 | branch for features. It's also convenient to tag all commits in the master branch with a version number. 63 | 64 | 65 | #### Feature Branches 66 | Each new feature should reside in its own branch, which can be pushed to the central repository for backup/collaboration. But, instead of branching off of master, feature branches use develop as their parent branch. When a feature is complete, it gets merged back into develop. Features should never interact directly with master. 67 | 68 | ##### Creating a feature branch 69 | Without the git-flow extensions: 70 | ``` 71 | git checkout develop 72 | git checkout -b feature_branch 73 | ``` 74 | When using the git-flow extension: 75 | ``` 76 | git flow feature start feature_branch 77 | ``` 78 | 79 | ##### Publishing a feature branch 80 | Without the git-flow extensions: 81 | ``` 82 | git push origin feature_branch 83 | ``` 84 | When using the git-flow extension: 85 | ``` 86 | git flow feature publish feature_branch 87 | ``` 88 | 89 | Get a feature published by another user. 90 | ``` 91 | git flow feature pull origin feature_branch 92 | ``` 93 | 94 | You can track a feature on origin by using 95 | ``` 96 | git flow feature track feature_branch 97 | ``` 98 | 99 | ##### Finishing a feature branch 100 | When you’re done with the development work on the feature, the next step is to merge the feature_branch into develop. 101 | 102 | Without the git-flow extensions: 103 | ``` 104 | git checkout develop 105 | git merge feature_branch 106 | ``` 107 | 108 | Using the git-flow extensions: 109 | 110 | ``` 111 | git flow feature finish feature_branch 112 | ``` 113 | 114 | #### Bugfix Branches 115 | After finishing feature branch, if you get bug then you can create bugfix branch. Like as feature branch it will be always created from develop branch. 116 | 117 | ##### Creating a bugfix branch 118 | ``` 119 | git flow bugfix start bugfix_branch 120 | ``` 121 | 122 | ##### Publishing a feature branch 123 | 124 | ``` 125 | git flow bugfix publish bugfix_branch 126 | ``` 127 | 128 | 129 | ##### Finishing a bugfix branch 130 | When you’re fixed bug, the next step is to merge the bugfix_branch into develop. 131 | ``` 132 | git flow bugfix finish bugfix_branch 133 | ``` 134 | 135 | #### Release Branches 136 | 137 | Creating this branch starts the next release cycle, so no new features can be added after this point—only bug fixes, documentation generation, and other release-oriented tasks should go in this branch. Once it's ready to ship, the release branch gets merged into master and tagged with a version number. 138 | 139 | ##### Creating a release branch 140 | 141 | Without the git-flow extensions: 142 | 143 | ``` 144 | git checkout develop 145 | git checkout -b release/0.1.0 146 | ``` 147 | 148 | When using the git-flow extensions: 149 | 150 | ``` git flow release start 0.1.0 ``` 151 | 152 | Switched to a new branch 'release/0.1.0 153 | 154 | ##### Finishing a release branch 155 | To finish a release branch, use the following methods: 156 | 157 | Without the git-flow extensions: 158 | ``` 159 | git checkout master 160 | git merge release/0.1.0 161 | ``` 162 | When using the git-flow extension:: 163 | ``` 164 | git flow release finish '0.1.0' 165 | ``` 166 | 167 | Once the release is ready to ship, it will get merged it into master and develop, then the release branch will be deleted. 168 | It’s important to merge back into develop because critical updates may have been added to the release branch and they need to 169 | be accessible to new features. If your organization stresses code review, this would be an ideal place for a pull request. 170 | 171 | Don't forget to push your tags with ```git push origin --tags ``` 172 | 173 | 174 | #### Hotfix Branches 175 | 176 | Maintenance or “hotfix” branches are used to quickly patch production releases. Hotfix branches are a 177 | lot like release branches and feature branches except they're based on master instead of develop. 178 | This is the only branch that should fork directly off of master. As soon as the fix is complete, it should be merged into both master and 179 | develop (or the current release branch), and master should be tagged with an updated version number. 180 | 181 | ##### Creating a hotfix branch 182 | Without the git-flow extensions: 183 | ``` 184 | git checkout master 185 | git checkout -b hotfix_branch 186 | ``` 187 | When using the git-flow extensions: 188 | 189 | ``` 190 | git flow hotfix start hotfix_branch 191 | ``` 192 | 193 | ##### Finishing a hotfix branch 194 | Without the git-flow extensions: 195 | ``` 196 | git checkout master 197 | git merge hotfix_branch 198 | git checkout develop 199 | git merge hotfix_branch 200 | git branch -D hotfix_branch 201 | ``` 202 | 203 | When using the git-flow extensions: 204 | ``` 205 | git flow hotfix finish hotfix_branch 206 | ``` 207 | 208 | 209 | ### The overall flow of Gitflow is: 210 | - A develop branch is created from master 211 | - Feature branches are created from develop 212 | - When a feature is complete it is merged into the develop branch 213 | - Bugfix branches are created from develop 214 | - When bug fixed are done it is merged into the develop branch 215 | - Release branch is created from develop 216 | - When the release branch is done it is merged into develop and master 217 | - If an issue in master is detected a hotfix branch is created from master 218 | - When the hotfix is complete it is merged to both develop and master 219 | -------------------------------------------------------------------------------- /feature1.php: -------------------------------------------------------------------------------- 1 |