Skip to content
This repository has been archived by the owner on Feb 25, 2020. It is now read-only.

Git Flow

Buster Darragh-Major edited this page Mar 26, 2019 · 6 revisions

Note: Please ensure you have read Git Setup before rebasing/submitting pull requests

Fork/Rebase

Make sure your master is up to date with Kelly’s master by running git pull. If you completed the Git Setup correctly, this should pull from Kelly’s repository.

Creating a branch

Create a new branch from your local master branch. Use the following naming conventions:

  • git checkout -b feature/[ISSUE-NUMBER]-[UPI]-ISSUE-NAME
  • git checkout -b fix/[ISSUE-NUMBER]-[UPI]-ISSUE-NAME

Making local changes

Make some changes to your branch using git commit and git push. In order to minimise merge conflicts, rebase often with git pull --rebase upstream master. This will keep the code in your local repo up to date with what is in Kelly’s repo (our master repo). If issues occur with this step refer to the troubleshooting section.

Creating a PR

Once all your changes are ready, create a pull request. Pull requests should have the following naming convention: [*Issue Number*] Issue Title.

Notify somebody on the team that you have created a pull request (on slack, or in person). The reviewer should pull your branch and test that it works, before approving the pull request. If the reviewer has any problems, they should use GitHub's inline comments and request for changes.

Testing someone's PR

If you followed the setup above, use the following command to checkout the pull request branch locally: git fetch origin pull/PULL_REQUEST_NUMBER/head:BRANCH_NAME

Once the pull request is ready to merge, select “Merge and squash commits”.

Troubleshooting

If any issues occur with rebasing from upstream attempt the following steps. If issues persist seek help from one of the team's Git specialists.

Undoing bad git commands

So you did an faulty rebase and maybe you've tried to push this to your forked origin URL, it hasn't worked. Now your'e in a messy state where you can't push for whatever reason. To troubleshoot this go git reflog and you will see an output similar to that below.

In this case I want to reset to the head at 10, as it represents the state before I attempted to rebase erroneously. In this case, I would execute git reset HEAD@{10}. This would get me back to the state without removing the changes subsequent commands would have made to my local repository. Because I want to remove these changes entirely, I would instead go git reset --hard HEAD@{10}. (Note: as with all reset --hards, please please please make sure any changes you want to keep are committed.)

Fixing rebase URL

Ensure your origin and upstream URLs are configured correctly. A common issue for the team has been the origin fetch URL being the upstream URL, instead of the forked origin URL. Execute the command git remote -v your output should look similar to below.

If your output displays the upstream URL after either origin tag or vice versa, execute the command git remote set-url [origin/upstream] [url]. For example, to set the fetch URL for one's origin execute git remote set-url origin [personal forked repo url].

Clone this wiki locally