Skip to content

Git Configuration

Yash Satyavarpu edited this page Oct 15, 2020 · 2 revisions

General workflow information (Git, Pull Requests, branching, etc..):

Unless you are working on a bug in a specific release, always create a branch from master. Each JIRA issue should have its own branch. JIRA issues have 4 categories. To create a working branch before working on an issue:

  1. features:
    git checkout master
    git checkout -b feature-[JIRA_ID]-[briefDescriptionOfFeature]
  1. bugs:
    git checkout master
    git checkout -b bug-[JIRA_ID]-[briefDescriptionOfBug]
  1. improvements:
    git checkout master
    git checkout -b improvement-[JIRA_ID]-[briefDescriptionOfImprovement]
  1. tasks:
    git checkout master
    git checkout -b task-[JIRA_ID]-[briefDescriptionOfTask]

Example:

git checkout -b feature-FEMR832-fixingEverythingEverywhere

Staying in sync with the main repository

Always sync your fork's (username/femr) master branch with the project's (femr/femr) master branch. If your working branch begins to deviate too far from master, merging will becoming increasingly difficult. This ensures that your work remains in sync with everyone else's work:

  1. List your current remotes to see if you have one pointing upstream to the main project repository (femr/femr):
    git remote -v
  1. If you do not, add one:
    git remote add upstream https://github.com/femr/femr.git
  1. Sync your updated local master branch with your fork's master branch:
    git checkout master
    git pull upstream master
    git push origin master

If you have committed your work to master, you will run into issues here. Move your work to a separate working branch and get a fresh copy of the master branch.

  1. This step requires rebasing. Sync your working branch with your fork and rebase new code into your working branch: git checkout [issueBranchName] git push origin [issueBranchName] git rebase master

  2. After confirming your code was properly merged and that the rebase was successful, sync the new branch with your fork: git checkout [issueBranchName] git push -f origin [issueBranchName]

    Note the '-f' option for push in Step 5. This forces a push because the rebase has altered your commit history. Anyone else that was using your branch will need to delete it and pull down a fresh copy.

Submit your code for review to be accepted into the main project repository (femr/femr) by sending a Pull Request from your fork on GitHub:

  1. Update your branch with the newest code by syncing master and then rebasing your working branch. See Step 4 and Step 5 in the previous section to complete this.

  2. Initiating a pull request:

Initiate a pull request from your fork's (username/femr) working branch into the main repository's (femr/femr) master branch.

  1. If your Pull Request is Accepted git checkout master git pull upstream master

  2. If your Pull Request requires additional commits you can add them to your branch and push to your fork. They will automatically be updated in the Pull Request.

    git checkout [issueBranchName]
    ~~~make changes, commit them~~~
    git push origin [issueBranchName]
  1. If your Pull Request is Rejected
    git checkout master
    git pull upstream master
    git checkout [issueBranchName]
    git rebase master
    ~~~fix issues~~~
    git checkout master
    git pull upstream master
    git checkout [issueBranchName]
    git rebase master
    git push -f origin [issueBranchName]
  1. Delete your branch locally:
    git branch -d [issueBranchName]
  1. Delete your branch from your fork:
	git push origin :[issueBranchName]