Skip to content

Commit 45db38d

Browse files
Initial gh wps (#408)
Co-authored-by: Jenny Hickson <61183013+jennyhickson@users.noreply.github.com>
1 parent 68ad212 commit 45db38d

16 files changed

+364
-10
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
.. _forking:
2+
3+
Creating and Managing Forks
4+
===========================
5+
6+
.. tip::
7+
8+
For more information see the `github documentation <https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks>`_
9+
10+
Forks are repositories that share code and visibility settings with the upstream repository. They provide a place for development work to take place while allowing the upstream repo to maintain limited write access. Forks can all merge branches with each other as well as with the upstream repository, meaning a pull request can be opened to merge a branch in a fork into the upstream main.
11+
12+
Creating a Fork
13+
---------------
14+
15+
Creating a fork is something that only needs to be done once per upstream repository. Once created, branches can be created in the fork as desired by the owner.
16+
17+
.. tab-set::
18+
19+
.. tab-item:: Web Browser
20+
21+
First navigate to the upstream repository you wish to fork. Then select the fork button.
22+
23+
.. image:: images/gh_screenshots/fork_button_light.png
24+
:class: only-light
25+
26+
.. image:: images/gh_screenshots/fork_button_dark.png
27+
:class: only-dark
28+
29+
On the next page you can rename your fork if desired and select which branches to fork - ensure this box is unticked to fork all branches.
30+
31+
.. important::
32+
33+
Ensure the option to only clone the default branch is unticked.
34+
35+
.. image:: images/gh_screenshots/fork_page_light.png
36+
:class: only-light
37+
38+
.. image:: images/gh_screenshots/fork_page_dark.png
39+
:class: only-dark
40+
41+
.. tab-item:: gh cli
42+
43+
Run the following command, substituting for the required upstream owner and repository name,
44+
45+
.. code-block::
46+
47+
gh repo fork <OWNER>/<REPO>
48+
49+
.. tip::
50+
51+
Add ``--clone`` to immediately clone the forked repo
52+
53+
54+
Maintaining a Fork
55+
------------------
56+
57+
Most work to maintain a fork involves syncing it with the upstream repository. Syncing a fork will ensure that changes to the upstream repository are copied into the fork. Syncing is done on a per branch basis. For example, after a new release, syncing the ``stable`` branch will ensure the forks ``stable`` branch contains the newly released code.
58+
59+
.. important::
60+
61+
It is recommended that developers do not modify the synced branches from upstream in their forks as this may cause issues with merge conflicts when syncing a fork. Instead all work should be carried out in a branch.
62+
63+
.. tab-set::
64+
65+
.. tab-item:: Web Browser
66+
67+
Navigate to your fork in github that you wish to sync. Select the ``Sync Fork`` button and if required, update the branch. This will only sync the branch you are currently on - to sync other branches select one from the branch dropdown menu. You may want to sync both ``stable`` and ``main``, particularly at a release.
68+
69+
.. image:: images/gh_screenshots/sync_fork_light.png
70+
:class: only-light
71+
72+
.. image:: images/gh_screenshots/sync_fork_dark.png
73+
:class: only-dark
74+
75+
.. tab-item:: gh cli
76+
77+
Run the following command, substituting for the downstream fork owner and repo name. Without the ``-b`` option, only the default branch will be synced. You may want to sync both ``stable`` and ``main``, particularly at a release.
78+
79+
.. code-block::
80+
81+
gh repo sync <OWNER>/<REPO> -b <BRANCH>
82+
83+
.. tip::
84+
85+
When using the gh cli to sync forks, remember that it won't pull the changes to local clone, this needs to be done manually.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.. _gh_authorisation:
2+
3+
Setting Up Github Authorisations
4+
================================
5+
6+
A brief overview of how to set up authorisations to gh for Sim Sys or links to relevant instructions.
7+
8+
* ssh keys
9+
* verified commits
10+
* gh command line
11+
* Maybe more?
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
.. _gh_dev_init:
2+
3+
Beginning a Github Development
4+
==============================
5+
6+
This section will guide you through the development process assuming you are already authorised with github (:ref:`gh_authorisation`) and have already created a fork (:ref:`forking`).
7+
8+
Create an Issue
9+
---------------
10+
11+
.. important::
12+
13+
It is not guaranteed that opening an issue will result in action or even visibility by the relevant maintainers or code owners. If you think a team or individual should be aware of an issue, then contact them directly in addition to opening an issue.
14+
15+
An issue in github can be used to document a problem in the codebase or as somewhere to document the development process for a new feature. Sub-issues can also be created if a large piece of work wants breaking down into smaller sections. If you are working on an issue, then assign yourself to it so that others know that you are working on it. Issues are created in the upstream repository.
16+
17+
.. tab-set::
18+
19+
.. tab-item:: Web Browser
20+
21+
Navigate to the ``Issues`` tab for the relevant **upstream** repo and select the ``New Issue``. Write an suitable title and description, and use the options on the right as desired/appropriate.
22+
23+
.. image:: images/gh_screenshots/issues_light.png
24+
:class: only-light
25+
26+
.. image:: images/gh_screenshots/issues_dark.png
27+
:class: only-dark
28+
29+
.. tab-item:: gh cli
30+
31+
The following command can be used to create an issue from the command line. The available options can be seen in the `gh cli documentation <https://cli.github.com/manual/gh_issue_create>`_.
32+
33+
.. code-block::
34+
35+
gh issue create -R <OWNER>/<REPO> [options]
36+
37+
There is no requirement to open an issue before making a pull request, as long as the change documentation is sufficient. For instance, small changes may not benefit from the separate issue.
38+
39+
40+
Clone the Repository
41+
--------------------
42+
43+
A clone is a local copy of a repository - you can have a local clone of either an upstream repository or a fork. A clone will have an active branch which will initially be the default branch of the repository. All other branches in the repository can be accessed using the ``checkout`` command (see below). For general development, you should now get a clone of your fork.
44+
45+
.. tip::
46+
47+
For those familiar with svn/fcm, a clone is the git equivalent to a working copy. However, unlike a working copy, which can only access a single branch, a clone can be switched to any branch in the repository.
48+
49+
.. tab-set::
50+
51+
.. tab-item:: git commands
52+
53+
To clone a repository using git, run the following in a terminal:
54+
55+
.. code-block::
56+
57+
git clone <URL> <CLONE_NAME>
58+
59+
where ``CLONE_NAME`` is the desired directory name of the clone. It will default to the name of the repository.
60+
61+
The ``URL`` can be found from github,
62+
63+
.. image:: images/gh_screenshots/clone_button_light.png
64+
:class: only-light
65+
66+
.. image:: images/gh_screenshots/clone_button_dark.png
67+
:class: only-dark
68+
69+
selecting the url as desired.
70+
71+
.. tab-item:: gh cli
72+
73+
To clone a repository using gh cli run the following command,
74+
75+
.. code-block::
76+
77+
gh repo clone <OWNER>/<REPO> <CLONE_NAME>
78+
79+
where ``CLONE_NAME`` is the desired directory name of the clone. It will default to the name of the repository.
80+
81+
.. tip::
82+
83+
Using gh cli to clone a fork will automatically add the upstream repository as a remote source which can be helpful.
84+
85+
86+
Create a Branch
87+
---------------
88+
89+
Branches for developing Simulation Systems repositories should generally be branched from ``stable`` where this exists (some smaller repositories only contain a ``main`` branch). Creating a branch from ``main`` may be acceptable if the development is continuing on from a ticket already committed at that release.
90+
91+
To create a branch and switch to it from the command line, the syntax is,
92+
93+
.. code-block::
94+
95+
git branch <branch_name> <parent_branch>
96+
git checkout <branch_name>
97+
98+
# or
99+
100+
git checkout <parent_branch>
101+
git checkout -b <branch_name>
102+
103+
.. note::
104+
105+
It is also possible to create a new branch via github in a web browser.
106+
107+
108+
Developing a Change
109+
-------------------
110+
111+
Now that you have a new branch, you are ready to begin development. See :ref:`development_index`, for advice on how to plan and implement new developments in a Simulation Systems repository, including advice on Metadata, KGO's and testing.
112+
113+
.. tip::
114+
115+
To see the status of your current clone you can run ``git status``
116+
117+
While developing you will likely want to commit your changes and push to the remote repository. First you will need to stage any files that have been modified and you would like to include in your commit,
118+
119+
.. code-block::
120+
121+
git add path/to/file1 [path/to/file2...]
122+
123+
And then commit the change,
124+
125+
.. code-block::
126+
127+
git commit -m "An Informative Commit Message"
128+
129+
.. tip::
130+
131+
In git you do not need to commit all modified files unlike in svn/fcm. It is also possible to only commit certain parts of a modified file. For more information see the relevant man page, ``man git add``.
132+
133+
Finally, you may want to push any commits stored in your local clone.
134+
135+
.. code-block::
136+
137+
git push
138+
139+
.. important::
140+
141+
Unlike svn/fcm, committing in git will not push your changes to the remote server. The ``git push`` command must also be used to do this.
142+
143+
144+
41.4 KB
Loading
41.9 KB
Loading
26.7 KB
Loading
26.5 KB
Loading
43.9 KB
Loading
42.6 KB
Loading
38.6 KB
Loading

0 commit comments

Comments
 (0)