A place to understand how to use Pull Requests with git-flow.
We assume the following:
- You have git flow (AVH Edition) installed,
- You have Github's CLI installed.
The example app is written in Go, but it does not really matter as we will not even compile it.
For instructions using Bitbucket, please go to the Bitbucket repository.
For instructions using GitLab, please go to the GitLab repository.
Using gh, let's clone this sandbox:
gh repo clone gildas/gitflow-pr-sandboxOnce inside the repository, initialize git flow:
git flow initMake sure to:
- name the
developbranchdev(I never liked that long label) - set the version tag prefix to
v
If you want to use my git flow hooks, go to its folder, and initialize the hooks with the path of your repository folder:
./hook-it ~/Documents/path/to/gitflow-pr-sandboxThis will initialize git flow, and copy the appropriate hooks.
Let's start our feature:
git flow feature start myfeatureAdd and commit some changes...
You can share the feature with fellow developers by pushing the branch to the repository (do not use git flow feature publish since we will use it to create the Pull Request).
git push --set-upstream origin feature/myfeatureor
git push -u origin feature/myfeatureOnce the feature is finished, publish the feature:
git flow feature publish myfeatureIf you use my git flow hooks, the Pull Request will be automatically created.
Otherwise, create the Pull Request:
gh pr create \
--title "Merge feature myfeature" \
--body "Feature myfeature" \
--base devNow, as the Pull Request reviewer, log on github and merge the Pull Request without deleting the feature branch. Or use the CLI:
gh pr merge \
--subject 'Merged feature myfeature'Back to the feature owner, grab the merge:
git checkout dev
git pullAnd finish the feature:
git flow feature finish myfeatureSince preparing a release usually involves the master branch, typically, the people that take care of that task are usually the maintainers of the project.
Let's start a new release:
git flow release start 1.0.0If you use my git flow hooks, you will get the auto-versioning for node.js and Go based projects.
If not, you should modify your project's version manually, in the current case:
sed -Ei '/VERSION\s+=/s/[0-9]+\.[0-9]+\.[0-9]+/1.0.0/' version.go
git add version.go
git commit -m "Bumped to version 1.0.0" version.goYou can also share the release branch with others by pushing it to the repository (like features):
git push -u origin release/1.0.0When all bugs have been fixed and the QA process is done, the release should be published to created a Pull Request:
git flow release publishIf you use my git flow hooks, the Pull Request will be automatically created.
Otherwise, create the Pull Request:
gh pr create \
--title "Merge release 1.0.0" \
--body "Release 1.0.0." \
--base masterNow, as the Pull Request reviewer, log on github and merge the Pull Request without deleting the release branch. Or use the CLI:
gh pr merge \
--subject 'Merged release 1.0.0'Back to the release baker, grab the merge:
git checkout master
git pullAnd finish the release:
git flow release finish 1.0.0Let's start a new hotfix:
git flow hotfix start 1.0.1If you use my git flow hooks, you will get the auto-versioning for node.js and Go based projects.
If not, you should modify your project's version manually, in the current case:
sed -Ei '/VERSION\s+=/s/[0-9]+\.[0-9]+\.[0-9]+/1.0.1/' version.go
git add version.go
git commit -m "Bumped to version 1.0.1" version.goYou can also share the hotfix branch with others by pushing it to the repository (like features and releases):
git push -u origin hotfix/1.0.1When all bugs have been fixed and the QA process is done, the hotfix should be published to created a Pull Request:
git flow hotfix publishIf you use my git flow hooks, the Pull Request will be automatically created.
Otherwise, create the Pull Request:
gh pr create \
--title "Merge hotfix 1.0.1" \
--body "Hotfix 1.0.1" \
--base masterNow, as the Pull Request reviewer, log on github and merge the Pull Request without deleting the hotfix branch. Or use the CLI:
gh pr merge \
--subject 'Merged hotfix 1.0.1'Back to the hotfix maker, grab the merge:
git checkout master
git pullAnd finish the hotfix:
git flow hotfix finish 1.0.1