Collaborating with Git
If you’re working on a data model as part of a team you can take inspiration from the Gitflow Workflow to effectively collaborate and develop your data model. The following is a recommendation, so feel free to use another approach if there’s one that suits your team better.
- Start with a main branch for your team. Because there is already a
main
branch in the repository, we suggest you create a branch from themain
branch and name it something likeproject-name-main
orteam-name-main
. - Next Analyst 1 is working on
table_a
, while Analyst 2 is working ontable_b
.- Analyst 1 should create a branch off
project-name-main
calleda1/model-a-development
, prefixing the branch name with their initials and a slasha1/
. - Analyst 2 should create a branch off
project-name-main
calleda2/model-b-development
, prefixing the branch name with their initials and a slasha2/
.
- Analyst 1 should create a branch off
- When they have completed the development of their respective models, each analyst should raise a pull request for their respective branches and set the base branch to
project-name-main
. - The analysts, or someone else in the team, can then review the pull request and quality assure the work.
- When a pull request has been merged into
project-name-main
, keep other feature branches likea2/model-b-development
up to date by mergingproject-name-main
into it. You can do this using the terminal or in the pull request itself where you will see a button at the bottom of the pull request page that saysUpdate branch
. If you do use the pull request to update the branch, you’ll need to rungit pull
locally. When the data model is complete and all changes have been merged intoproject-name-main
, you can request review from the data modelling team who will check it over before it gets merged intomain
.
Creating branches
First make sure you’re on the main
branch by running the following in terminal:
git status
If you’re not, run:
git checkout main
git pull
Next create your project-name-main
branch (don’t forget to update the project name in the command) by running:
git checkout -b <project-name-main>
From the project-name-main
branch, create your development branch by running:
git checkout -b <a1/model-a-development>
replacing a1
with your initals.
Updating your branch with main
When working on your models it is likely that your branch will get out of date with the main branch. To update you branch with the latest changes from main open a terminal and run the following:
Check your working tree, commit/push any changes if required
git status
Switch to the main branch and collect the latest changes, if any
git switch main
git fetch
git pull
Switch back to your branch and merge in the changes from main
git switch <your_branch>
git merge main -m "update branch with main"
At this point you may have merge conflicts that need to be resolved; please see GitHub resolve merge conflicts. If required, ask for help on the #ask-data-modelling slack channel.