BANA409BANA409

Github Tutorial

In this tutorial, you need to setup your Github account and perform basic code management tasks. Note that this tutorial does not cover advanced features such as branching, conflict resolution, etc.

Task 1: Create a new repository and publish to Github

Screen Shot 2022-10-11 at 5.04.31 PM.png

Screen Shot 2022-10-11 at 3.46.28 PM.png

publish the repo:

Screen Shot 2022-10-11 at 3.50.24 PM.png

Now you can see your repo on Github.com.

Task 2: Basic Git Workflow (no collaboration with others)

If you don’t collaborate with others on the same repo, the basic git workflow is very simple.

  1. make changes to the repo, such as change the readme file, add new files using VSCODE.

    Screen Shot 2022-10-11 at 4.56.06 PM.png

  2. commit the changes (add the required summary):

    Screen Shot 2022-10-11 at 4.56.58 PM.png

  3. push the changes to the remote Github repo:

    Screen Shot 2022-10-11 at 5.08.01 PM.png

  4. change the visibility of your repo: by default, the repo is private. You can use the Github page to change the repo to public if needed:

Open your repo in Github.com and click the settings:

![Screen Shot 2022-10-11 at 5.23.09 PM.png](/images/github-tutorial-07-screen-shot-2022-10-11-at-5-23-09-pm.png)

Change the repo to public:

![Screen Shot 2022-10-11 at 5.24.04 PM.png](/images/github-tutorial-08-screen-shot-2022-10-11-at-5-24-04-pm.png)

![Screen Shot 2022-10-11 at 5.24.19 PM.png](/images/github-tutorial-09-screen-shot-2022-10-11-at-5-24-19-pm.png)

### Task 3 (optional -not covered in this class): Collaborate on a repository

Multiple people can work on a repo together. The workflow is as follows:

- a main repo is created (only owners and admins have write permission to this repo)
- contributors fork the repo to their accounts
- contributors clone their own forks
- each contributor works on the project and commit the changes to their fork
- push the changes to their forks
- issue a pull request to merge their contributions into the main repo

an exercise:

- fork [https://github.com/hjwang/misy225-f22](https://github.com/hjwang/misy225-f22) to your account
    
    ![Screen Shot 2022-10-11 at 10.04.16 PM.png](/images/github-tutorial-10-screen-shot-2022-10-11-at-10-04-16-pm.png)
    
    ![Screen Shot 2022-10-11 at 10.08.22 PM.png](/images/github-tutorial-11-screen-shot-2022-10-11-at-10-08-22-pm.png)
    
- then find the url for your fork and clone your fork
    
    ![Screen Shot 2022-10-11 at 7.02.43 PM.png](/images/github-tutorial-12-screen-shot-2022-10-11-at-7-02-43-pm.png)
    
    ![Screen Shot 2022-10-11 at 10.09.43 PM.png](/images/github-tutorial-13-screen-shot-2022-10-11-at-10-09-43-pm.png)
    

choose the first option:

![Screen Shot 2022-10-11 at 10.10.39 PM.png](/images/github-tutorial-14-screen-shot-2022-10-11-at-10-10-39-pm.png)

add a txt file to the cloned fork:

![Screen Shot 2022-10-11 at 10.11.48 PM.png](/images/github-tutorial-15-screen-shot-2022-10-11-at-10-11-48-pm.png)

commit the change and push to origin repo (your fork)

![Screen Shot 2022-10-11 at 10.12.32 PM.png](/images/github-tutorial-16-screen-shot-2022-10-11-at-10-12-32-pm.png)

![Screen Shot 2022-10-11 at 10.12.45 PM.png](/images/github-tutorial-17-screen-shot-2022-10-11-at-10-12-45-pm.png)

then open the repo on Github.com:

![Screen Shot 2022-10-11 at 10.16.21 PM.png](/images/github-tutorial-18-screen-shot-2022-10-11-at-10-16-21-pm.png)

then, create a pull request, i.e. tell the parent repo owner that you have some contribution ready to be merged.

![Screen Shot 2022-10-11 at 10.15.54 PM.png](/images/github-tutorial-19-screen-shot-2022-10-11-at-10-15-54-pm.png)

![Screen Shot 2022-10-11 at 10.16.54 PM.png](/images/github-tutorial-20-screen-shot-2022-10-11-at-10-16-54-pm.png)

![Screen Shot 2022-10-11 at 10.17.19 PM.png](/images/github-tutorial-21-screen-shot-2022-10-11-at-10-17-19-pm.png)

then, the pull requests can be seen from the parent repo’s webpage and the owner/admin can choose to merge your pull request to get your contribution into the parent repo.

Once the parent repo (referred to as upstream) has new merges from other people, you can update your fork by pulling down the merges via Github:

![Screen Shot 2022-10-13 at 9.44.58 AM.png](/images/github-tutorial-22-screen-shot-2022-10-13-at-9-44-58-am.png)

Then, you can use Github Desktop to pull the updates to your local computer:

![Screen Shot 2022-10-13 at 9.45.58 AM.png](/images/github-tutorial-23-screen-shot-2022-10-13-at-9-45-58-am.png)

On this page