Git Forked Repository Operations: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 27: Line 27:


<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
git clone git@github.example.com:ovidiu-feodorov/blue.git
git clone git@github.com:ovidiu/blue.git
</syntaxhighlight>
</syntaxhighlight>
=Setup Relationships=
==Setup the "upstream" Repository==
Establish a direct relationship with the "upstream" repository:
<syntaxhighlight lang='bash'>
git remote add upstream git@github.com:blue/blue.git
</syntaxhighlight>
This will allow us to fetch directly from "upstream"
<syntaxhighlight lang='bash'>
git fetch upstream
</syntaxhighlight>
==Configure the "main" Branch to Update From Upstream==
git fetch upstream
git branch --set-upstream-to=upstream/main main


=PR Cycle=
=PR Cycle=

Revision as of 22:10, 1 November 2023

External

Internal

Overview

For terminology, see upstream/base and head repositories.

Fork

Go to GitHub UI and click on the "Fork" button at the top of the page.

Where should we work <project-name>? 

Use your own "personal" organization.

Forking <original-org>/<project-name>

Clone

Clone as usual:

git clone git@github.com:ovidiu/blue.git

Setup Relationships

Setup the "upstream" Repository

Establish a direct relationship with the "upstream" repository:

git remote add upstream git@github.com:blue/blue.git

This will allow us to fetch directly from "upstream"

git fetch upstream


Configure the "main" Branch to Update From Upstream

git fetch upstream git branch --set-upstream-to=upstream/main main

PR Cycle

Send a PR

Push the commit in the head repository.

It will show up in the UI.

Click "Compare & pull request"

The UI will give you the default choice to send the PR against the base repository while "Create pull request". Use it.

Merge the PR

Upon approval ...

How to deal with the leftover branch?

Sync the Repository after the PR Merge

From the GitHub UI

In the fork repository UI, use "Fetch upstream" button. Then git pull from the local clone.

CLI

TODO: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

How to deal with the leftover branch in the head repository?