User Tools

Site Tools


development:ohdsi_github_projects_v2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
development:ohdsi_github_projects_v2 [2016/10/19 18:39]
chrisknoll
development:ohdsi_github_projects_v2 [2016/10/19 22:13]
chrisknoll
Line 22: Line 22:
 ==== Code Management ==== ==== Code Management ====
  
-The following section is described how to work with source code in a Git repository. It provides a general overview of using Git and explains how to provide code contributions. Subsequently,​ the Release Management ​section ​will focus on best practices and conventions for controlling versions and releases of the source code in a repository. ​+The following section is described how to work with source code in a Git repository. It provides a general overview of using Git and explains how to provide code contributions. Subsequently,​ the [[Release Management]] article ​will focus on best practices and conventions for controlling versions and releases of the source code in a repository. ​
  
 === Forking and Cloning === === Forking and Cloning ===
Line 145: Line 145:
  
 If you wanted to contribute your commits from '​new-feature-branch'​ in your repository, you would navigate to your branch in GitHub, click New pull request, and then chose the target repository (OHDSI/​Atlas for example) and the branch to apply your commits to (usually '​master'​). ​ The only difference between an internal collaborator Pull Request and an External Collaborator Pull Request is that the Internal Collaborator will be making a pull request between 2 branches within the OHDSI repository, and the External Collaborator will be making a pull request between the branch in the External Collaborator'​s fork and the branch in the OHDSI repository. ​ Otherwise, it is exactly the same process. If you wanted to contribute your commits from '​new-feature-branch'​ in your repository, you would navigate to your branch in GitHub, click New pull request, and then chose the target repository (OHDSI/​Atlas for example) and the branch to apply your commits to (usually '​master'​). ​ The only difference between an internal collaborator Pull Request and an External Collaborator Pull Request is that the Internal Collaborator will be making a pull request between 2 branches within the OHDSI repository, and the External Collaborator will be making a pull request between the branch in the External Collaborator'​s fork and the branch in the OHDSI repository. ​ Otherwise, it is exactly the same process.
 +
 +=== Fetching and Merging changes ===
 +
 +At some point during your feature branch development,​ another pull request may have been applied to master, or some other commit may have been applied to master before you issued your pull request. ​ This means that your branch is '​behind'​ master by a number of commits. ​ Not only that, it means that there'​s new code in master that you should be using in your branch so that when it's time to commit to master, you don't have any conflicts or bugs that could arise from the code changes. ​ To solve this, you "​rebase"​ your branch onto the tip of master.  ​
 +
 +Before you rebase, however, you must ensure that you have the latest version of master from the remote repository.
 +
 +<​code>​
 +$ git fetch origin
 +remote: Counting objects: 72, done.
 +emote: Total 72 (delta 24), reused 24 (delta 24), pack-reused 48
 +Unpacking objects: 100% (72/72), done.
 +From https://​github.com/​OHDSI/​WebAPI
 +   ​1327c1f..0f3297c ​ shiro      -> origin/​shiro
 +</​code>​
 +
 +In the above example, the '​shiro'​ branch was updated to a new commit based on changes in the remote shiro branch.  ​
 +
 +**Note:** This command returns no output if nothing has changed on the remote.
 +
 +Once the remote branches (including master) have been fetched, you can then rebase your feature branch on top of the latest tip of master.
 +
 +<​code>​
 +$ git rebase origin/​master new-feature-branch
 +</​code>​
 +
 +**Note:** the new-feature-branch parameter is not required if the active branch is '​new-feature-branch'​. ​ Additionally,​ after you execute this command the active branch will be set to '​new-feature-branch'​.
 +
 +Visually, the rebase performed like this:
 +
 +{{:​development:​images:​rebase.png}}
 +
 +Now that the new-feature-branch has been moved to the tip of origin/​master,​ all changes that have been made to origin/​master are now reflected in new-feature-branch. ​ It is important to remember that before creating a Pull Request from your feature branch that your branch shows 'zero commits behind master'​ before it is created. If your branch is behind master, it must be rebased before submitting a pull request.
 +
 +=== Working inside a Shared Branch ===
 +
 +For private, single-developer branches, rebasing is the cleanest method of incorporating upstream changes into your branch. ​ However, once a branch is pushed to the remote repository and other developers are working together in the same branch, rebasing should be avoided. ​ Instead, each developer pulls changes from the remote repository and pushes commits as needed:
 +
 +Developer 1 creates the new feature branch:
 +<​code>​
 +$ git checkout -b shared-feature
 +Switched to a new branch '​shared-feature'​
 +...hack hack hack....
 +$ git add .
 +$ git commit -m "my new feature"​
 +</​code>​
 +
 +From here, Developer 2 may want to get involved with this feature, so Developer 1 pushes the branch, and Developer 2 pulls and checks out the branch.
 +
 +Developer 1 pushes using the -u flag so that the remote branch will be tracked:
 +<​code>​
 +$ git push -u origin
 +</​code>​
 +
 +Developer 2 fetches the new branch:
 +<​code>​
 +$ git fetch origin
 +* [new branch] ​      -> origin/​shared-feature
 +$ git checkout -b shared-feature origin/​shared-feature
 +</​code>​
 +
 +Now Developer 2 is working inside a local branch "​shared-feature'​ that is tracking the remote origin/​shared-feature branch.
 +
 +Developer 1 and Developer 2 are now sharing this branch, and will use git pull and git push to merge changes into the shared-feature branch. ​ After development is completed, a new '​rebased'​ branch will be created on to master which will be the branch that the pull request will be made from:
 +
 +Either Developer 1 or Developer 2 can perform this, but only one of them needs to do this to create the pull request branch:
 +
 +<​code>​
 +$ git fetch origin
 +$ git checkout shared-feature
 +$ git checkout -b shared-feature-pr # creating a new branch at the tip of the shared-feature branch; active branch is now "​shared-feature-pr"​
 +$ git rebase origin/​master
 +$ git push origin
 +</​code>​
 +
 +The shared-feature-pr will contain a copy of the commits from shared-feature branch, but applied to the top of the master branch. After pushing, the branch will be available on github as a **head** of the pull request. ​ The pull request is created using the base of master and the head is set to shared-feature-pr. ​ Note: development on the feature should now continue under the shared-feature-pr branch. The old "​shared-feature"​ branch can be deleted.
 +
 +
 +
 +
 +
 +
 +
 +
  
  
development/ohdsi_github_projects_v2.txt ยท Last modified: 2017/02/02 14:41 by chrisknoll