During this example we'll follow two Acme developers, Jamie Bowen & Jamie Public as they collaborate on a new project.
OpenFLOW central lives in the Community project area of the ForgeRock Bitbucket Server. ForgeRock have created a fork of the project for Acme, also in the Community project area. This fork is called
Jamie Bowen has created a Jira ticket for the creation of a project README.md, it's ID is OpenFLOW-1640 and created a branch from master for work called
Both Jamie Bowen and Jamie Public have created private forks of the OpenFLOW-Acme repository.
In his private repository Jamie Bowen created the initial README file, pushed it to his private fork of OpenFLOW-Acme on the BitBucket server and then created a pull request from that fork in that repository into the OpenFLOW repository's
OpenFLOW-1640-write-into-readme-section branch. He then created a branch from
feature/OpenFLOW-1640-write-into-readme-section-jbowen where he will work on the readme.
In Jamie Public's private repository he's created a branch from
feature/OpenFLOW-1640-write-into-readme-section-jpublic where he will work on the readme.
Here we can see that Jamie Bowen has added Line 1 to the readme and pushed it to his private fork on the Bitbucket Server;
Jamie Public has Added line 2 to the README.md file and pushed that to his private form of OpenFLOW-Acme;
Now Jamie Bowen creates a pull request to have commit
937f2fb2e40 into the main feature branch,
feature/OpenFLOW-1640-write-into-readme-section's of the OpenFLOW-Acme central repository;
Then, after review the pull request gets merged into the Community OpenFLOW-Acme's feature branch, resulting in a commit graph that looks like this;
So now it comes time for Jamie Public to create a pull request for his branch in order to merge commit
2f5b908ecb0 into the main feature branch in the OpenFLOW-Acme central repository. This pull request is from;
This time, the merge fails due to a merge conflict;
To resolve the merge conflicts;
Step 1: Fetch changes from the target repository (saving the target branch as FETCH_HEAD).
git fetch https://stash.forgerock.org/scm/com/openflow-acme.git feature/OpenFLOW-1640-write-intro-readme-section
Step 2: Checkout the source branch and merge in the changes from the target branch. Resolve conflicts.
git checkout feature/OpenFLOW-1640-write-intro-readme-section-jpublic
git merge FETCH_HEAD
Step 3: After the merge conflicts are resolved, stage the changes accordingly, commit the changes and push.
git add README.md
git push https://stash.forgerock.org/scm/~bohocode/openflow-acme.git HEAD
Which leaves the git commit graph looking like this;
Obtaining in the Latest Project Changes
At some point during development it may be essential to merge in changes from the central repo's master branch. This can happen for a number of reasons:
- You have hit a bug that existed in the commit the feature branch was branched from which is preventing testing of your new feature.
- Your new feature depends upon another feature or changes that have been made in another feature branch that has now been incorporated into central's master branch.
To do this you will need to merge master into your team fork's feature branch.
If fork syncing was turned on when your team repository was forked from the central repository you can merge your team repository's master branch into the feature branch in order to gain all the changes committed to central's master branch. Individuals will then need to merge the team branch into their work branches. As a private fork's feature branch is synced with the team repository's feature branch you can merge the feature branch in your repository into your work branch locally.
Let's say that we need to read some config for our feature, and that the config reading code has been developed by another team, and that work is now in the master branch;
We need to pull this into out feature branch in order to continue development. Jamie Public will do this work;