Skip to content

Commit

Permalink
feat: creating separate section for setting up repo with Git (open-sa…
Browse files Browse the repository at this point in the history
  • Loading branch information
jdwilkin4 committed Oct 10, 2023
1 parent 584dcbc commit d68a086
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 42 deletions.
44 changes: 3 additions & 41 deletions docs/technical/resolve-merge-conflicts.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,10 @@ In literally every case it is advised _**not**_ to use the `Resolve conflicts` b

The above will at best achieve a ready to merge pull request with visible inconsistencies.

## Repository setup

Fork and clone the project using the `gh` command line interface:

```shell
gh repo clone 0-vortex/open-sauced
```

Running `git remote -v` will output:

```shell
origin git@github.com:0-vortex/open-sauced.git (fetch)
origin git@github.com:0-vortex/open-sauced.git (push)
upstream git@github.com:open-sauced/open-sauced.git (fetch)
upstream git@github.com:open-sauced/open-sauced.git (push)
```

Fork and clone the project using the `git` command line interface:

```shell
git clone git@github.com:0-vortex/open-sauced.git
```

Running `git remote -v` will output:

```shell
origin git@github.com:0-vortex/open-sauced.git (fetch)
origin git@github.com:0-vortex/open-sauced.git (push)
```

As an additional step for this tutorial we need to add the `upstream` remote:

```shell
git remote add upstream git@github.com:open-sauced/open-sauced.git
```

## Update

First get the default branch changes:


```shell
git fetch origin --recurse-submodules=no --progress --prune
git checkout main --
Expand All @@ -68,7 +31,6 @@ git merge upstream/main --no-stat -v

Then merge with the forked up-to-date `beta` (default branch):


```shell
git merge origin/main --no-ff -v
```
Expand All @@ -93,7 +55,6 @@ It will look like this:

Since this pull request does not modify the `package.json` file it is safe to fast forward the changes from `origin/main`:


```shell
# overwrite with origin/main changes
git show :3:package.json > package.json
Expand Down Expand Up @@ -153,8 +114,9 @@ And it's ready to merge:
When dealing with dependency and lock file updates there are multiple use cases to consider, however as a baseline, the OpenSauced triage team will not prioritize parallel main features as seen in the roadmap.

However when that happens, it is advised to:
- fast-forward `npm-shrinkwrap.json`
- fast-forward deleted and modified `upstream/beta` changes to `package.json`

- fast-forward `npm-shrinkwrap.json`
- fast-forward deleted and modified `upstream/beta` changes to `package.json`
- fast-forward your added lines to `package.json`
- run `npm ci` to delete local modules and create dependency resolution from `upstream/beta`

Expand Down
70 changes: 70 additions & 0 deletions docs/technical/setup-repo-with-git.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
id: setup-repo-with-git
title: Setting up a repository with Git and GitHub
sidebar_label: Setting up a repository with Git and GitHub
keywords:
- Setting up a repository with Git and GitHub
---

## Using the GitHub CLI

### How to install the GitHub CLI

The [GitHub CLI](https://cli.github.com/) allows you to fork repositories, create issues, pull requests, and more from the command line.

The GitHub CLI can be installed on Mac, Windows or Linux. You can find the complete installation instructions [here](https://github.com/cli/cli#installation).

### How to authenticate with the GitHub CLI

From the terminal, you will need to authenticate with the GitHub CLI. You can do this by running the following command:

```shell
gh auth login
```

Follow the on screen prompts to authenticate with the GitHub CLI.

### How to fork and clone a repository with the GitHub CLI

A fork is a copy of a repository and it allows you to freely experiment with changes without affecting the original project.

A clone is a local copy of a repository that includes all the files, branches, and commits.

To fork and clone a repository with the GitHub CLI, run the following command:

```shell
gh repo fork open-sauced/REPO_NAME
```

The GitHub CLI will fork the project in your GitHub account and will ask you if you want to clone the repository on your local machine.

### How to view the remote repositories locally

To view the remote repositories that your local repository is connected to, run the following command:

```shell
git remote -v
```

You should see the following output:

```shell
origin git@github.com:YOUR_GITHUB_USERNAME/open-sauced.git (fetch)
origin git@github.com:YOUR_GITHUB_USERNAME/open-sauced.git (push)
upstream git@github.com:open-sauced/open-sauced.git (fetch)
upstream git@github.com:open-sauced/open-sauced.git (push)
```

### How to add a remote repository

To pull in changes from the original repository, you will need to add a remote repository. To do this, run the following command:

```shell
git remote add upstream git@github.com:open-sauced/open-sauced.git
```

This will allow you to pull in changes from the original repository and keep your forked copy of the repository up to date.

## Using the GitHub website and the command line

If you prefer to setup your repository using the GitHub website and the command line, then you can follow this detailed guide from the [official GitHub documentation](https://docs.github.com/en/get-started/quickstart/fork-a-repo).
6 changes: 5 additions & 1 deletion sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ module.exports = {
type: "category",
label: "Technical guide",
collapsed: false,
items: ["technical/introduction-to-storybook", "technical/resolve-merge-conflicts"],
items: [
"technical/introduction-to-storybook",
"technical/setup-repo-with-git",
"technical/resolve-merge-conflicts",
],
},
{
type: "category",
Expand Down

0 comments on commit d68a086

Please sign in to comment.