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
.
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.
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!
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).
-
Clone your own fork with
git clone [email protected]:<jbusecke>/<xgcm>.git
and navigate to the resulting folder. -
Add a remote for the PRs author (in this case
rabernat
) withgit remote add <rabernat> [email protected]:<rabernat>/<xgcm>.git
-
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>
-
Make some changes, add, commit.
-
Push back to the PR branch:
git push -u <rabernat> <what_you_want>:<vertical-grid>