-
-
Notifications
You must be signed in to change notification settings - Fork 309
How to: keep your fork in sync #2663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3ee332a
How to: sync your fork
jaimergp 244a23f
more info on conflict resolution
jaimergp 345ba36
Merge branch 'main' into how-to-fork
jaimergp 79a687f
Update docs/how-to/basics/fork-sync.md
jaimergp 93a1dc1
adjust some wording
jaimergp 958e85b
Apply suggestions from code review
jaimergp d53d582
Update docs/how-to/basics/fork-sync.md
jaimergp 39e3e6c
Update docs/how-to/basics/fork-sync.md
jaimergp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| --- | ||
| tags: [how-to, basic] | ||
| --- | ||
|
|
||
| # How to keep your fork in sync | ||
|
|
||
| The `conda-forge` workflow assumes that contributors will _always_ open their pull requests from their feedstock fork. Follow these best practices to make sure your branches are always up-to-date. | ||
|
|
||
| ## Terminology | ||
|
|
||
| Given a `conda-forge/package-feedstock` repository, Github allows you to create a copy on your account, called _fork_. You have full rights over your forked repository, and it should be the place where you experiment with new branches and changes. | ||
|
|
||
| The original repository is usually referred to as `upstream`. | ||
|
|
||
| ## How to fork a feedstock | ||
|
|
||
| Forks are easily created from the Github UI: | ||
|
|
||
| 1. Go to the conda-forge feedstock | ||
| 2. Click on the Fork button in the top right corner | ||
| 3. Select on which account you want to create the fork. Choose your personal account, not an organization. | ||
|
|
||
| ## How to keep your fork in sync | ||
|
|
||
| Never push directly to your fork's `main` branch. This branch should always be identical to upstream. This way your new branches will never start with merge conflicts. | ||
|
|
||
| You can sync your fork `main` with upstream's via the Github UI. Look for an option named "Sync". Then, in your local copy of the forked repository, run: `git checkout main && git pull`. | ||
|
|
||
| Locally, you can follow these steps: | ||
|
|
||
| 1. If not available on disk yet, clone your fork and change into its directory. | ||
| 2. Change the branch to `main`: `git checkout main`. | ||
| 3. Pull from upstream: `git pull --ff-only upstream main`. | ||
|
|
||
| If this results in a "not possible to fast-forward" error, check [the section below](#how-to-resolve-conflicts-in-main). | ||
|
|
||
| Once `main` is synced, you can create a new branch with `git checkout -b new-branch-name`. | ||
|
|
||
| ## How to resolve conflicts in `main` | ||
|
|
||
| When pulling from `upstream`, you might run into merge conflicts or "not possible to fast-forward" errors. This can happen if you pushed to your fork's `main` branch instead of creating a new one. | ||
|
|
||
| If you don't care about your local changes, you can simply do `git reset --hard upstream/main`. | ||
| If you want to save your changes but still make your fork's `main` identical to `upstream`'s: | ||
|
|
||
| 1. If you just tried to `pull` and got merge conflicts, abort with `git merge --abort`. Otherwise, check the info in `git status` and make sure you are you are in the `main` branch: `git checkout main`. | ||
| 2. Park your local `main` in separate branch, as a backup: `git checkout -b parked-changes`. | ||
| 3. Ensure your remotes are fresh: `git fetch upstream`. | ||
| 4. Go back to `main` and reset it to `upstream`'s: `git checkout main && git reset --hard upstream/main`. | ||
|
|
||
| Alternatively, create a backup of your `main` branch with `git checkout main && git checkout -b parked-changes` | ||
| and then try to pull with a rebase strategy with `git rebase -i upstream/main`. | ||
| The idea here is to keep only the commits from `upstream` and drop the ones you added yourself. | ||
jaimergp marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| [Gitlab's docs on `git rebase`](https://docs.gitlab.com/topics/git/git_rebase/) contain more details on this type of workflow. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.