Difference between revisions of "GitHub"

From NoskeWiki
Jump to navigation Jump to search
(Created page with "==GitHub== I'm actually not very good at all at "GitHub", but what I do know is that I work with a developer to create my own App and we used "GitHub Desktop" and it seemed t...")
 
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
==GitHub==
 
==GitHub==
  
I'm actually not very good at all at "GitHub", but what I do know is that I work with a developer to create my own App and we used "GitHub Desktop" and it seemed to work okay.
+
{{ChildPage|parent=[[Git]]}}
 +
 
 +
GitHub ([https://github.com/ github.com]) is a web-based platform that provides hosting for software development and version control using Git. It offers a range of features and functionalities that support collaboration among developers.
 +
 
 +
{{Prettyblockquote}}
 +
Here's a detailed overview of what GitHub offers:
 +
 
 +
* '''Repository Hosting''': GitHub allows users to host and manage Git repositories. A repository (or repo) is where all the files of a particular project are stored, along with their revision history.
 +
* '''Collaboration''': GitHub is designed for collaboration. Multiple developers can work on the same project from anywhere in the world. They can contribute to each other's projects by forking a repository, making changes, and proposing those changes back to the original repository via pull requests.
 +
* '''Code Review''': GitHub provides tools for code review within pull requests. Other developers can comment on the changes, suggest improvements, or approve the modifications before they are merged into the main branch of the project.
 +
* '''Issue Tracking''': GitHub offers an issue tracking feature that allows users to track and manage bugs, enhancements, and other tasks within a project. Users can create, assign, and comment on issues, making it easier to manage project tasks.
 +
* '''GitHub Actions''': GitHub Actions is a CI/CD (Continuous Integration/Continuous Deployment) feature that enables automation of workflows and tasks, such as testing and deploying code.
 +
* '''Project Management''': GitHub provides tools like [https://en.wikipedia.org/wiki/Kanban_board Kanban boards], milestones, and labels that help in organizing and prioritizing work on a project.
 +
* '''Documentation''': With GitHub, you can host documentation alongside your code. This is often done using a special repository named wiki or by using the README files in the repositories.
 +
* '''GitHub Pages''': Users can host their static websites directly from their GitHub repositories with GitHub Pages.
 +
* '''Social Networking Features''': GitHub incorporates many social networking-like features such as follows, stars, and a news feed that shows updates from repositories and users you are interested in.
 +
* '''Marketplace''': GitHub Marketplace offers a variety of developer tools that can be integrated into GitHub to improve workflow and productivity.
 +
* '''Security Features''': GitHub provides several security features like security advisories, automated vulnerability scanning, and integration with security tools to help keep code safe.
 +
* '''Open Source Community''': GitHub hosts a vast community of open source projects. Users can contribute to these projects by submitting pull requests or reporting issues.
 +
</blockquote>
 +
 
 +
Overall, GitHub is an essential tool for developers, providing a platform for hosting, sharing, and collaborating on code. It has become a central hub for open-source projects and a standard tool in the professional software development process.
 +
 
 +
Projects on GitHub can be either public or private, depending on the user's preferences and settings.
 +
 
 +
 
 +
 
 +
==Setting Up Github==
 +
 
 +
The Github website helps you through the process and any commands needed to help set up a new project.
 +
 
 +
For instance:
 +
 
 +
<syntaxhighlight lang="bash">
 +
$ git remote add origin http://github.com/noske/MyWebsite.com.git
 +
</syntaxhighlight>
 +
 
 +
... to push ALL branches try:
 +
 
 +
<syntaxhighlight lang="bash">
 +
$ git push --all
 +
</syntaxhighlight>
 +
 
 +
... to pull ALL the latest use:
 +
 
 +
<syntaxhighlight lang="bash">
 +
$ git pull
 +
</syntaxhighlight>
 +
 
 +
In GitHub, you can actually make changes DIRECTLY, although it's best to use an IDE like [[VS Code]] for big projects.
 +
 
 +
 
 +
 
 +
==Pull Request==
 +
 
 +
This means a change has to be approved before it's submitted. It's a little counterintuitive to call it a "pull request" because a pull is usually from a remote repo onto your local... but think of it as the action taken by the owner of the repo... you are requesting that they pull your local changes into their repo.
 +
 
 +
If you have write access, then you can use a "branch" approach, if not you'll have to use a "fork" approach ''(creating your whole own version)''. Here's some steps:
 +
 
 +
* '''Clone the Repository'''
 +
** Launch GitHub Desktop.
 +
** Go to ''File > Clone repository''. Choose the repository and select where to clone it.
 +
* '''Create a New Branch'''
 +
** Click on ''Current branch'' and then ''New branch''.
 +
** Give your branch a descriptive name.
 +
** Click ''Create Branch''.
 +
* '''Make Changes in the New Branch'''
 +
** Open the project in your code editor.
 +
** Edit, add, or delete files.
 +
** Save your changes in the editor.
 +
* '''Commit the Changes'''
 +
** Return to GitHub Desktop to see a list of changed files.
 +
** Select the files you want to commit.
 +
** Write a commit message and click ''Commit to [your-branch-name]''.
 +
* '''Publish/Sync the Branch'''
 +
** If first time, click ''Publish branch''.
 +
** If already published, click ''Push origin''.
 +
* '''Create the Pull Request'''
 +
** Go to ''Repository'' in GitHub Desktop and select ''View on GitHub''.
 +
** On the GitHub page, click ''Compare & pull request''.
 +
** Provide a title and description.
 +
** Click ''Create pull request''.
 +
* '''Review and Discussion'''
 +
** Participate in the review process.
 +
* '''Making Additional Changes (if needed)'''
 +
** Make additional changes, commit, and push as before.
 +
* '''Merging the Pull Request'''
 +
** Merge the pull request into the main branch.
 +
** The pull request will be marked as closed.
 +
* '''Clean Up'''
 +
** Delete the feature branch after merging.
 +
 
 +
 
 +
 
 +
==Tricks==
 +
 
 +
===Adding To GitHub Workflow: `build`, `tests`, `DO NOT SUBMIT` and other checks===
 +
 
 +
You'll never want to submit code that breaks your build! In your code repo, under `.github/workflows` you can add files like this:
 +
 
 +
'''.github/workflows/app.yml'''
 +
 
 +
<syntaxhighlight lang="yaml">
 +
name: Your app build + checks
 +
on: [push]
 +
 
 +
jobs:
 +
  build:
 +
    runs-on: ubuntu-latest
 +
    steps:
 +
      - uses: actions/checkout@v2
 +
      - name: Build docker image
 +
        run: |
 +
          cd frontend
 +
          docker build -t app .
 +
</syntaxhighlight>
 +
 
 +
'''.github/workflows/backend.yml'''
 +
 
 +
<syntaxhighlight lang="yaml">
 +
name: Backend linting
 +
on: [push]
 +
 
 +
jobs:
 +
  build:
 +
    runs-on: ubuntu-latest
 +
    steps:
 +
      # Copy code over
 +
      - uses: actions/checkout@v2
 +
      - name: Install dependencies
 +
        run: |
 +
          pip install black pylint
 +
          black --check backend
 +
</syntaxhighlight>
 +
 
 +
'''.github/workflows/check_for_forbidden_phrases.yml'''
 +
 
 +
<syntaxhighlight lang="yaml">
 +
name: Check for DO NOT SUBMIT
 +
on: [pull_request]
 +
# Actually you'd want this on [push] too.
 +
 
 +
jobs:
 +
  check:
 +
    runs-on: ubuntu-latest
 +
    steps:
 +
    - uses: actions/checkout@v2
 +
    - name: Check for forbidden phrase
 +
      run: |
 +
        if grep -r "DO NOT SUBMIT" . ; then
 +
          echo "Error: Found 'DO NOT SUBMIT' in the code."
 +
          exit 1
 +
        fi
 +
</syntaxhighlight>
 +
 
 +
 
 +
 
 +
 
 +
==Videos==
 +
 
 +
* [https://www.youtube.com/watch?v=tRZGeaHPoaw&ab_channel=KevinStratvert Git and GitHub Tutorial for Beginners] - Long, but useful.
 +
* [https://www.youtube.com/watch?v=8Dd7KRpKeaE&ab_channel=CoderCoder Git, GitHub, & GitHub Desktop for beginners] - Good info, shows a "Pull Request" in brief.
 +
 
 +
==See Also==
 +
 
 +
* '''[[Git]]''' - The open-source distributed version control system on which GitHub is based.
 +
* '''[[VS Code]]''' - A very popular IDE with some extensions to work with GitHub.
  
 
==Links==
 
==Links==
Line 9: Line 175:
  
  
[[Category:Computers]]
+
[[Category:Programming]]

Latest revision as of 19:30, 18 December 2023

GitHub

This page is a child of: Git


GitHub (github.com) is a web-based platform that provides hosting for software development and version control using Git. It offers a range of features and functionalities that support collaboration among developers.

Here's a detailed overview of what GitHub offers:

  • Repository Hosting: GitHub allows users to host and manage Git repositories. A repository (or repo) is where all the files of a particular project are stored, along with their revision history.
  • Collaboration: GitHub is designed for collaboration. Multiple developers can work on the same project from anywhere in the world. They can contribute to each other's projects by forking a repository, making changes, and proposing those changes back to the original repository via pull requests.
  • Code Review: GitHub provides tools for code review within pull requests. Other developers can comment on the changes, suggest improvements, or approve the modifications before they are merged into the main branch of the project.
  • Issue Tracking: GitHub offers an issue tracking feature that allows users to track and manage bugs, enhancements, and other tasks within a project. Users can create, assign, and comment on issues, making it easier to manage project tasks.
  • GitHub Actions: GitHub Actions is a CI/CD (Continuous Integration/Continuous Deployment) feature that enables automation of workflows and tasks, such as testing and deploying code.
  • Project Management: GitHub provides tools like Kanban boards, milestones, and labels that help in organizing and prioritizing work on a project.
  • Documentation: With GitHub, you can host documentation alongside your code. This is often done using a special repository named wiki or by using the README files in the repositories.
  • GitHub Pages: Users can host their static websites directly from their GitHub repositories with GitHub Pages.
  • Social Networking Features: GitHub incorporates many social networking-like features such as follows, stars, and a news feed that shows updates from repositories and users you are interested in.
  • Marketplace: GitHub Marketplace offers a variety of developer tools that can be integrated into GitHub to improve workflow and productivity.
  • Security Features: GitHub provides several security features like security advisories, automated vulnerability scanning, and integration with security tools to help keep code safe.
  • Open Source Community: GitHub hosts a vast community of open source projects. Users can contribute to these projects by submitting pull requests or reporting issues.

Overall, GitHub is an essential tool for developers, providing a platform for hosting, sharing, and collaborating on code. It has become a central hub for open-source projects and a standard tool in the professional software development process.

Projects on GitHub can be either public or private, depending on the user's preferences and settings.


Setting Up Github

The Github website helps you through the process and any commands needed to help set up a new project.

For instance:

$ git remote add origin http://github.com/noske/MyWebsite.com.git

... to push ALL branches try:

$ git push --all

... to pull ALL the latest use:

$ git pull

In GitHub, you can actually make changes DIRECTLY, although it's best to use an IDE like VS Code for big projects.


Pull Request

This means a change has to be approved before it's submitted. It's a little counterintuitive to call it a "pull request" because a pull is usually from a remote repo onto your local... but think of it as the action taken by the owner of the repo... you are requesting that they pull your local changes into their repo.

If you have write access, then you can use a "branch" approach, if not you'll have to use a "fork" approach (creating your whole own version). Here's some steps:

  • Clone the Repository
    • Launch GitHub Desktop.
    • Go to File > Clone repository. Choose the repository and select where to clone it.
  • Create a New Branch
    • Click on Current branch and then New branch.
    • Give your branch a descriptive name.
    • Click Create Branch.
  • Make Changes in the New Branch
    • Open the project in your code editor.
    • Edit, add, or delete files.
    • Save your changes in the editor.
  • Commit the Changes
    • Return to GitHub Desktop to see a list of changed files.
    • Select the files you want to commit.
    • Write a commit message and click Commit to [your-branch-name].
  • Publish/Sync the Branch
    • If first time, click Publish branch.
    • If already published, click Push origin.
  • Create the Pull Request
    • Go to Repository in GitHub Desktop and select View on GitHub.
    • On the GitHub page, click Compare & pull request.
    • Provide a title and description.
    • Click Create pull request.
  • Review and Discussion
    • Participate in the review process.
  • Making Additional Changes (if needed)
    • Make additional changes, commit, and push as before.
  • Merging the Pull Request
    • Merge the pull request into the main branch.
    • The pull request will be marked as closed.
  • Clean Up
    • Delete the feature branch after merging.


Tricks

Adding To GitHub Workflow: `build`, `tests`, `DO NOT SUBMIT` and other checks

You'll never want to submit code that breaks your build! In your code repo, under `.github/workflows` you can add files like this:

.github/workflows/app.yml

name: Your app build + checks
on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Build docker image
        run: |
          cd frontend
          docker build -t app .

.github/workflows/backend.yml

name: Backend linting
on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      # Copy code over
      - uses: actions/checkout@v2
      - name: Install dependencies
        run: |
          pip install black pylint
          black --check backend

.github/workflows/check_for_forbidden_phrases.yml

name: Check for DO NOT SUBMIT
on: [pull_request]
# Actually you'd want this on [push] too.

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Check for forbidden phrase
      run: |
        if grep -r "DO NOT SUBMIT" . ; then
          echo "Error: Found 'DO NOT SUBMIT' in the code."
          exit 1
        fi



Videos

See Also

  • Git - The open-source distributed version control system on which GitHub is based.
  • VS Code - A very popular IDE with some extensions to work with GitHub.

Links