soda4fries / WIA1002_S2_24_occ9

Repo for Datastructure OCC9
MIT License
1 stars 15 forks source link

How to contribute from your Fork for Labs #17

Open soda4fries opened 3 months ago

soda4fries commented 3 months ago

create a tutorial for the forking and sumitting lab works

github-actions[bot] commented 3 months ago

Wah your first issue

Nas-Mohd commented 3 months ago

Forking a Repository

Before we can make changes, or rather propose changes to the repository, we must first make a fork of the repository to serve as our copy. We will be making our changes to the fork then making pull requests to try and update the repository based on our changes.

A fork is a new repository that shares code and visibility settings with the original “upstream” repository.

  1. Go to the repository page and click the fork button

image_2024-04-17_231658681

  1. You will be directed to a page to confirm and edit the fork of the repository. Just hit the "Create Fork" button at the bottom of the page. image_2024-04-17_232326443

  2. Wait for a bit then you will now have your own fork of the repository.

Making Changes and Pull Requests

With the fork that we now have, we can make changes to the fork and try to push them into the original repository by way of making pull requests.

A pull request is a proposal to merge a set of changes from one branch into another. In a pull request, collaborators can review and discuss the proposed set of changes before they integrate the changes into the main codebase.

Make sure your computer has Git installed.

  1. There are two ways to go about editing and making changes to the fork.

    • Through GitHub. GitHub allows you to upload files and create new files directly. image_2024-04-17_234445198

    • Through your own terminal or IDE. VSCode, IntelliJ, NetBeans and all the other common IDEs have Git and version control functionalities integrated that you can use to clone your fork to make changes.

  2. For your initial pull request, head to the "Labs" directory and create a new folder named after your matric number. In GitHub, you can do the following:

    • Click 'Add File' then 'Create New File' image
    • Name the file "(Matric Number)/hi.txt". It will look something like this: image
    • Type 'hi' or anything you want in the file. image
  1. After making changes and committing, you can now open a pull request. Go to your fork repository page. If you notice, there is a text now saying that "This branch is X commits ahead of (upstream repository). You can either click the "X commits ahead of" hypertext or the 'Contribute' button and hit 'Open pull request' image

  2. You will be directed to a page that shows which branch will be requested to be pulled to what other branch. The differences/changes will also be shown down below, but honestly just hit 'Create pull request' (cause i'm also still learning this stuff 💀 ) image

  3. Lastly add a title for the pull request and hit 'Create pull request' image

Congrats you have now made a pull request and will be added to be a collaborator soon ^^

Fetching and Syncing Your Fork

Now that you are able to make changes to the repository by updating your fork and making pull requests, there is another thing to keep track of. The original repository can and will be updated and these changes will not be automatically added to your fork. So you will need to 'fetch' these new changes into your own fork or copy of the repo.

Fetching is used to retrieve new work done by other people.

Using GitHub

Using a terminal

  1. Navigate first to your repository in the terminal if you aren't in it. Then run the following codes: git remote add upstream https://github.com/soda4fries/WIA1002_S2_24_occ9 git fetch upstream git checkout main git merge upstream/main

Tip: Syncing your fork only updates your local copy of the repository. To update your fork on GitHub.com, you must push your changes.