Skip to content

Latest commit

 

History

History
71 lines (47 loc) · 2.65 KB

git_instructions.md

File metadata and controls

71 lines (47 loc) · 2.65 KB

How to checkout a Pull Request locally and test it

An even easier method

Within your desired environment you can just do:

python -m pip install git+https://github.com/<user>/<repo>.git@refs/pull/<123>/head

EDIT: Just using pip instead of python -m pip recently failed for me. Apparently it is better practice to use python -m pip.

source

Values in <> need to be filled in by the user. For the xgcm case this would be:

python -m pip install git+https://github.com/xgcm/xgcm.git@refs/pull/205/head

This enables you to quickly test a new feature. If you want to make modifications and push back to github, I recommend the 'full' method below.

The manual method

First navigate to wherever you store your code and in that directory clone the repository in question, e.g.

git clone [email protected]:xgcm/xgcm.git

And then navigate to the new folder (in this case it will be named xgcm)

To check out a specific PR I follow these instructions.

git fetch origin pull/ID/head:BRANCHNAME
git checkout BRANCHNAME

The ID needs to match the PR number (here 205) and BRANCHNAME can you any name you want for the new branch

This should work:

git fetch origin pull/205/head:testing_new_feature

git checkout testing_new_feature

Now you have to install the package and you are ready to go. Depending on how you manage your packages, this means activating a specific conda environment (where you want to install) and then within the xgcm folder do

pip install -e .

And that should be it!

Pick up somebody else PR and edit it

Example illustrated with how I made edits to xgcm/#205 xgcm fork (replace values within <> appropriately (e.g. replace jbusecke with your username and xgcm with the package you are working on).

  1. Clone your own fork with git clone [email protected]:<jbusecke>/<xgcm>.git and navigate to the resulting folder.

  2. Add a remote for the PRs author (in this case rabernat) with git remote add <rabernat> [email protected]:<rabernat>/<xgcm>.git

  3. Fetch the other persons PR branch (here vertical-grid) and check out under any local name:

git fetch <rabernat>
git checkout -b <what_you_want> <rabernat>/<vertical-grid>
  1. Make some changes, add, commit.

  2. Push back to the PR branch: git push -u <rabernat> <what_you_want>:<vertical-grid>