Skip to content

Commit dd19371

Browse files
Add cherry-pick guide for fetching new material from upstream (#35)
based on updating Imageomics Guide from Collab template * Add link to cherry-pick guide for instructions on updating personalized sites * Fix typo in acknowledgments * Clarify description and add link to cherry-pick guide for more info * Add some intro to the page * Add a little extra context/clarity Co-authored-by: Matt Thompson <[email protected]> --------- Co-authored-by: Matt Thompson <[email protected]>
1 parent f0e5a9e commit dd19371

File tree

4 files changed

+87
-3
lines changed

4 files changed

+87
-3
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Please feel free to open an [issue](https://github.com/Imageomics/Collaborative-
1515

1616
This Guide is set up as a template repository such that there are two primary means of interacting with it:
1717

18-
1. Building a personalized version of the Guide: select "Use this Template" at the top of the repo to generate your own version. This will create a new repository (generated from the template repo) that does _not_ share the commit history of the template. Updates could still be added from the template upstream through [`git cherry-pick`](https://git-scm.com/docs/git-cherry-pick). More details are provided below, in [Personalizing the Guide](#personalizing-the-guide).
18+
1. Building a personalized version of the Guide: select "Use this Template" at the top of the repo to generate your own version. This will create a new repository (generated from the template repo) that does _not_ share the commit history of the template. Updates can still be added from the template upstream through `git cherry-pick` ([instructions](docs/wiki-guide/Git-Cherry-Pick-Guide.md)). More details are provided below, in [Personalizing the Guide](#personalizing-the-guide).
1919
2. Contributing to the Guide: fork this repo, make changes, and submit a pull request (PR) for review. Some guidance is provided in the [Pull Request Guide](https://imageomics.github.io/Collaborative-distributed-science-guide/wiki-guide/The-GitHub-Pull-Request-Guide/); please provide a detailed description of your changes and review the contributing guidelines (coming soon).
2020

2121
### Personalizing the Guide
@@ -59,4 +59,4 @@ This guide was developed alongside the [Imageomics Guide](https://imageomics.git
5959

6060
## Acknowledgments
6161

62-
This work was supported by both the [Imageomics Institute](https://imageomics.org) and the [AI and Biodiversity Change (ABC) Global Center](http://abcresearchcenter.org). The Imageomics Institute is funded by the US National Science Foundation's Harnessing the Data Revolution (HDR) program under [Award #2118240](https://www.nsf.gov/awardsearch/showAward?AWD_ID=2118240) (Imageomics: A New Frontier of Biological Information Powered by Knowledge-Guided Machine Learning). The ABC Global Climate Center is funded by the US National Science Foundation under [Award No. 2330423](https://www.nsf.gov/awardsearch/showAward?AWD_ID=2330423&HistoricalAwards=false) and Natural Sciences and Engineering Research Council of Canada under [Award No. 585136](https://www.nserc-crsng.gc.ca/ase-oro/Details-Detailles_eng.asp?id=782440). This guide draws on research supported by the Social Sciences and Humanities Research Council. Any opinions, findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation, Natural Sciences and Engineering Research Council of Canada, or Social Sciences and Humanities Research Council.
62+
This work was supported by both the [Imageomics Institute](https://imageomics.org) and the [AI and Biodiversity Change (ABC) Global Center](http://abcresearchcenter.org). The Imageomics Institute is funded by the US National Science Foundation's Harnessing the Data Revolution (HDR) program under [Award #2118240](https://www.nsf.gov/awardsearch/showAward?AWD_ID=2118240) (Imageomics: A New Frontier of Biological Information Powered by Knowledge-Guided Machine Learning). The ABC Global Center is funded by the US National Science Foundation under [Award No. 2330423](https://www.nsf.gov/awardsearch/showAward?AWD_ID=2330423&HistoricalAwards=false) and Natural Sciences and Engineering Research Council of Canada under [Award No. 585136](https://www.nserc-crsng.gc.ca/ase-oro/Details-Detailles_eng.asp?id=782440). This guide draws on research supported by the Social Sciences and Humanities Research Council. Any opinions, findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation, Natural Sciences and Engineering Research Council of Canada, or Social Sciences and Humanities Research Council.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Git Cherry-pick update for Downstream Repos
2+
3+
`git cherry-pick` is a handy tool to directly apply specific commits from one branch or repo to another even when they don't share a git history—especially when you do not want to merge large change sets. This can be helpful when forking another repo or building off an evolving template, such as this guide. Below, we provide a step-by-step guide to updating repositories based on the template guide repo:
4+
5+
!!! tip "Be Prepared!"
6+
Before you start, you should know which commits are going to be pulled from the template repo. Collect their hashes in a separate text file; be sure to list them in chronological order, so they can be applied correctly.
7+
8+
1. **Ensure the target repo is up-to-date.**
9+
2. Create a new branch onto which to pull the changes:
10+
11+
```console
12+
git checkout -b dev
13+
```
14+
15+
3. Check the remotes available for your repo:
16+
17+
```console
18+
git remote -v
19+
```
20+
21+
!!! note
22+
If you haven't updated yet, you will only see the current repo options (`origin`):
23+
24+
```console
25+
origin [email protected]:Imageomics/Imageomics-guide.git (fetch)
26+
origin [email protected]:Imageomics/Imageomics-guide.git (push)
27+
```
28+
29+
In which case, run the following to add the template guide as an available remote under the title `upstream`:
30+
31+
```console
32+
git remote add upstream [email protected]:Imageomics/Collaborative-distributed-science-guide.git
33+
```
34+
35+
After running `git remote -v`, you should then see
36+
37+
```console
38+
origin [email protected]:Imageomics/Imageomics-guide.git (fetch)
39+
origin [email protected]:Imageomics/Imageomics-guide.git (push)
40+
upstream [email protected]:Imageomics/Collaborative-distributed-science-guide.git (fetch)
41+
upstream [email protected]:Imageomics/Collaborative-distributed-science-guide.git (push)
42+
```
43+
44+
4. Run `git fetch upstream` to get the commits from the template repo (now recognized as `upstream`).
45+
5. Run `git cherry-pick --edit <first-commit-hash>`, this way, the URL pointing to the Collaborative Distributed Science Guide can be modified to function properly from the downstream repo. Ex:
46+
47+
```console
48+
git cherry-pick --edit a3d2f5d621aaa5b9a543fabad3f813ceb45964d4
49+
```
50+
51+
The next screen should provide the commit message for editing:
52+
53+
```console
54+
Update GitHub Repo Archiving Guidance (#29)
55+
56+
* Add section on automatically maintaining metadata on Zenodo
57+
...
58+
```
59+
60+
press ++i++, then, using arrow keys to navigate the console edit the message to the following:
61+
62+
```console
63+
Update GitHub Repo Archiving Guidance
64+
65+
Pull from Collab Guide [PR 29](https://github.com/Imageomics/Collaborative-distributed-science-guide/pull/29)
66+
67+
* Add section on automatically maintaining metadata on Zenodo
68+
...
69+
```
70+
71+
The URL will render as "[Imageomics/Collaborative-distributed-science-guide#29](https://github.com/Imageomics/Collaborative-distributed-science-guide/pull/29)", with the functional hyperlink. Finally, select ++esc++ and type `:wq` to complete the commit message edit.
72+
73+
!!! info "Conflicts Happen"
74+
If you have a merge conflict, open the file, resolve the conflict, and then `git add` the file. From that point you should be able to run `git cherry-pick --continue` and it will provide the commit message from the upstream. Checking `git status` and `git log` at various points in this process will allow you to check on how these are progressing and see the addition of the upstream commits to your current repo's branch.
75+
76+
6. Once you've collected all the upstream commits, run `git push --set-upstream origin dev` to add them to the current repo.
77+
7. Open a pull request from the `dev` branch to add these upstream commits to `main`. Be sure to include a description of the commits, where they came from, and include links to PRs _from the upstream repo_. Auto-links generated by GitHub (based on `#<issue/PR-number>`) will link to that number issue or PR in the current repo, not the upstream one.
78+
79+
8. Rebase commit the PR. This allows for the changes pulled from upstream to be seamlessly integrated into the downstream repo. The commit hashes are not preserved across repositories, so there is no information to lose.
80+
81+
See also [`git cherry-pick`](https://git-scm.com/docs/git-cherry-pick) for more info on available options.

docs/wiki-guide/Two-Repo-Problem.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,12 @@ This method is used when the same commits exist in both repos with different has
250250
This requires finding which commits are in the private repo but not in the public repo.
251251

252252
!!! warning "Warning"
253-
If the commits you cherry-pick have commits in common with different hashes this will result in merge conflicts and duplicated commits.
253+
If the commits you cherry-pick have content in common under commits with different hashes this will result in merge conflicts or duplicated commits. Be sure to list all commits to cherry-pick in chronological order before you begin.
254254

255255
After fetching your upstream branch you can cherry pick a range of commits to add like so:
256256

257257
```
258258
git cherry-pick <start-commit-hash>..<end-commit-hash>
259259
```
260+
261+
See the [Git Cherry-Pick Guide](Git-Cherry-Pick-Guide.md) for more details and an example of the full process.

mkdocs.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ nav:
109109
- "Projects Guide": wiki-guide/Guide-to-GitHub-Projects.md
110110
- "Branch Protections": wiki-guide/When-to-think-about-branch-protections.md
111111
- "Two Repo Problem": wiki-guide/Two-Repo-Problem.md
112+
- "Git Cherry-Pick Guide": wiki-guide/Git-Cherry-Pick-Guide.md
112113
# May want to personalize (on page as well): Why use the <organization/group> GitHub
113114
- "Why Use the Organization GitHub": wiki-guide/Why-use-the-organization-GitHub.md
114115
- Hugging Face Guide:

0 commit comments

Comments
 (0)