development:ohdsi_github_projects_v2
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| development:ohdsi_github_projects_v2 [2016/10/19 18:39] – chrisknoll | development:ohdsi_github_projects_v2 [2017/02/02 14:41] (current) – chrisknoll | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | OHDSI open-source development best practices (DRAFT) | + | ===== Github Contributor Best Practices ===== |
| Contributors: | Contributors: | ||
| Line 22: | Line 21: | ||
| ==== 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 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, |
| === Forking and Cloning === | === Forking and Cloning === | ||
| Line 145: | Line 144: | ||
| If you wanted to contribute your commits from ' | If you wanted to contribute your commits from ' | ||
| + | |||
| + | === Fetching and Merging changes === | ||
| + | |||
| + | At some point during your feature branch development, | ||
| + | |||
| + | Before you rebase, however, you must ensure that you have the latest version of master from the remote repository. | ||
| + | |||
| + | < | ||
| + | $ 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:// | ||
| + | | ||
| + | </ | ||
| + | |||
| + | In the above example, the ' | ||
| + | |||
| + | **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. | ||
| + | |||
| + | < | ||
| + | $ git rebase origin/ | ||
| + | </ | ||
| + | |||
| + | **Note:** the new-feature-branch parameter is not required if the active branch is ' | ||
| + | |||
| + | Visually, the rebase performed like this: | ||
| + | |||
| + | {{: | ||
| + | |||
| + | Now that the new-feature-branch has been moved to the tip of origin/ | ||
| + | |||
| + | === Working inside a Shared Branch === | ||
| + | |||
| + | For private, single-developer branches, rebasing is the cleanest method of incorporating upstream changes into your branch. | ||
| + | |||
| + | Developer 1 creates the new feature branch: | ||
| + | < | ||
| + | $ git checkout -b shared-feature | ||
| + | Switched to a new branch ' | ||
| + | ...hack hack hack.... | ||
| + | $ git add . | ||
| + | $ git commit -m "my new feature" | ||
| + | </ | ||
| + | |||
| + | 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: | ||
| + | < | ||
| + | $ git push -u origin | ||
| + | </ | ||
| + | |||
| + | Developer 2 fetches the new branch: | ||
| + | < | ||
| + | $ git fetch origin | ||
| + | * [new branch] | ||
| + | $ git checkout -b shared-feature origin/ | ||
| + | </ | ||
| + | |||
| + | Now Developer 2 is working inside a local 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. | ||
| + | |||
| + | Either Developer 1 or Developer 2 can perform this, but only one of them needs to do this to create the pull request branch: | ||
| + | |||
| + | < | ||
| + | $ 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 " | ||
| + | $ git rebase origin/ | ||
| + | $ git push origin | ||
| + | </ | ||
| + | |||
| + | 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. | ||
| + | |||
| + | === Syncing an upstream Fork === | ||
| + | |||
| + | In most cases, the repository you're contributing to is a fork of an OHDSI repository. | ||
| + | |||
| + | < | ||
| + | $ git fetch upstream # will fetch latest commits from the upstream repository | ||
| + | $ git checkout master | ||
| + | $ git merge upstream/ | ||
| + | </ | ||
| + | |||
| + | We force a --ff-only because the only commits that should be applied to your forked repository' | ||
| + | |||
| + | ==== Conclusion ===== | ||
| + | |||
| + | In summary, the main mode of contributing to OHDSI repositories is branching from the master, and submitting Pull Requests. | ||
| + | |||
| + | If there' | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
development/ohdsi_github_projects_v2.1476902394.txt.gz · Last modified: by chrisknoll
