Installing GitFlow on Windows
- Install cmder. Google it. Make sure you get the git for windows version.
- Download and install in C:\Program Files\Git\bin
a) getopt.exe from util-linux-ng package from the Binaries zip folder found at http://gnuwin32.sourceforge.net/packages/util-linux-ng.htm
b) libintl3.dll from libintl package from the Binaries zip folder found at http://gnuwin32.sourceforge.net/packages/libintl.htm
c) libiconv2.dll from libiconv2 package from the Binaries zip folder found at http://gnuwin32.sourceforge.net/packages/libiconv.htm
- Start cmder, which is a better command prompt console. Change folder to the one that you want to install gitflow in. It will install a gitflow folder under this.
4. Clone the gitflow repository.
git clone –recursive git://github.com/nvie/gitflow.git
5. Change to the gitflow folder
- Install gitflow, using the following command:
Contrib\msysgit-install.cmd “c:\Program Files\Git\”
Installing GitFlow in a repository
- Create your project folder: mkdir c:\demos\flow
- Change directory to the project folder: cd c:\demos\flow
- Initialise an empty Git repository: git init
- Initialise the repository for GitFlow: git flow init
Choose all the defaults.
The prompt should change show that you are in the c:\demos\flow (develop) branch.
- Checkout the master branch
git checkout master
- Make sure you have set up a repository on GitHub. On the github repository page, click on the Clone or download button and then click on the Use SSH link in the top right hand corner. Copy the link. Then execute the git remote command to set up the origin in git:
git remote add origin email@example.com:tonywr71/PSGitFlow.git
- Now push the origin to the master, to establish the github connection
git push –u origin master
- Change back to the develop branch
git checkout develop
- Now push the develop branch
git push origin develop
- If you go back to the repository page, you should now be able to select the two branches from the Branch drop down.
Creating a Feature Branch
- Make sure you have cloned the repository into a destination directory
git clone firstname.lastname@example.org:tonywr71/PSGitFlow.git .
Note the period (.) which is used to force it to be installed in the current directory, not a child of the current directory.
It will put you in the (master) branch
- Change to the develop branch
git checkout develop
- Initialise gitflow in the new folder if it hasn’t been done already
git flow init
and select all the defaults
- Go into github for this repository and select the Issue tab. We want the new feature to be associated with the issue. So add a new issue for the feature. The Issue number and issue subject should be part of the new feature name. The Issue Subject here would be “Users Can Access Single Entries” for example.
- Add a new feature branch
git flow feature start 2-UsersCanAccessSingleEntries
where 2 is the Issue number and UsersCanAccessSingleEntries is a concatenation of the issue subject. The command prompt will now show the feature branch:
- This branch hasn’t been pushed back into the repository yet, so there is no tracking in github. If you make changes to code in this folder, the prompt will now be highlighted in red, to show changes pending. If you want to see the pending changes, execute:
- To add the files into git
git add .
- To commit the repository locally, with a message:
git commit –am “Added code to get single entry”
This will change the command prompt folder back to white and commit the changes locally.
- To add the feature back onto the central repository
git flow feature publish 2-UsersCanAccessSingleEntries
- If you go into github, you can now select the feature branch from the Branch drop down
Reviewing a feature branch on another machine (or in another folder on the same machine)
- To see the list of feature sub-commands in gitflow:
git flow feature help
- To pull the feature into my local repository, switch you into that branch, but don’t track changes:
git flow feature pull 2-UsersCanAccessSingleEntries
- To pull the feature into my local repository, switch you into that branch and track changes to that feature:
git flow feature track 2-UsersCanAccessSingleEntries
- Make your changes in the tracked folder. In Cmder the command prompt will show a red feature folder. Again, you can see the pending changes by executing:
- Add the files that have been changed:
git add .
- Then commit them to the local repository with message:
git commit –am “Added exception handling”
- Finally, to push them to the central repository:
Get the reviewers changes back on the originator’s machine
- Check out the feature and pull it.
Finishing the Feature Branch and merging back into the develop branch
- The developer closes the branch, not the reviewer. The developer would click the Merge pull request button to merge back with the develop branch. The reviewer Closes the pull request, but doesn’t finish it. To finish the feature, the developer executes:
git flow finish 2-UsersCanAccessSingleEntries
- The feature branch is now deleted both locally and remotely, and you will have been switched back to the develop branch.
- Other developers that are using this feature will also need to delete their local branch. That is done by executing:
git checkout develop git branch –d 2-UsersCanAccessSingleEntries
- To check it has been removed
should no longer be showing the feature branch.
Creating a Release Branch
- This is the point in time where a release is ready.
- Once the Release Branch is created, it is passed to QA for testing.
- Any bugs that are found on the release branch will need to be fixed on the Release Branch and then merged back into the develop branch, so that any future feature branches will pick up those fixes.
- The architect creates the Release Branch by executing:
git flow release start sprint1-release
- The command prompt will show the new release folder, but this branch is currently only on the local machine. To publish this release so everyone can access it:
git flow release publish sprint1-release
- If you go into github and pull down the Branch drop down, you will see the new Release Branch.
Reviewing a Release Branch
- To view and track the release on someone else’s machine, set up a folder on that machine and execute:
git flow release track sprint1-release
- If someone makes changes to files in that branch, you can check the changes using
- You can then add any changes to the local repository
git add .
- Then commit the changes to the local repository
git commit –am “Add logging to exception (example message)”
- Then push the change to the remote repository
- The changes are now in the Release Branch, but need to be merged back to the develop branch.
git checkout develop
- Pull the develop branch
- Then merge it with the release branch
git merge release/sprint1-release
- That merge is local, so we now need to push changes back to the develop branch
Cleaning up the Release Branch and pushing to the master branch
- This job is done by the Architect, who will change to the Release Branch
git checkout release/sprint1-release
- Do a pull to make sure the local machine is up-to-date
- Now finish the release
git flow release finish sprint1-release
This will merge our flow back into the master branch and open up an emacs text editor to allow us to enter a more substantial release note. Save the text editor and exit. The release will be merged into the master branch and tagged with the release name. The tag is also back-merged into the develop branch. The release branch is also deleted both locally and remotely, and you are switched back to the develop branch.
- At this time, the develop branch is still checked out, so we need to change back to the master branch to check it all in.
git checkout master
When executing this command it will tell you how many commits there are difference between the master and the develop branch.
- We need to push all these changes including all the tags back to the remote repository.
git push –-tags
Creating a HotFix
- A Hot Fix is an emergency fix to released code. The Hot Fix is created on the master (production) branch. After making the fix on the Hot Fix Branch, it is then merged back into the master and develop branches.
- On the machine where the fix needs to occur, start the hotfix
git flow hotfix start hotfix1
Note that hotfix1 should match an issue in GitHub
- You will now be in the hotfix branch. Make changes to this branch and you can see the changes to the branch by typing
- Once the hotfix has been finished, the changes need to be committed:
git commit –am “Hot fix changes”
- The developer can then finish the hotfix by executing
git flow hotfix finish hotfix1
This will bring up the emacs text editor and you can add a hotfix release note, then save and close the editor and it will merge the hotfix into the master, tag it as hotfix1, back merge that tag into the develop branch, deleted the local hotfix1, and switch you into the develop branch.
- To see how many commits are outstanding on the develop branch, type
- You can also switch to the master branch and see where that is
git checkout master git status
- To push changes back to both remote branches, execute:
git push –-all origin