Skip to main content

Git and GitHub

What is Git?

Git is a popular version control system created by Linus Torvalds in 2005, and has been maintained by Junio Hamano since then. It is popular for collaborating on projects with multiple people. Git is able to track both code changes and who made those changes. It also allows you to revert your project to an earlier version if mistakes are made. Git is used by most developers/development studios.

How to Publish a Repository

  1. Make an account on GitHub.
  2. Click "New" in the sidebar on the homepage of your GitHub account.
  3. Give the repository a name and optional description.
  4. Click "Create repository"
  5. Under "Quick setup", click the copy button to copy a URL to the repository. You will use this in step 12.
  6. Enter a terminal on your computer.
  7. Change to the directory in which your files are stored with the command cd "PATH/TO/REPO".
  8. Create a README file with the command echo "# <repo_name>" >> README.md.
  9. Initialize Git in the directory with the command git init.
    • (optional) Rename the default branch using the command git branch -m <name>. The default name is "master".
  10. Add all files to the stage with the command git add --all.
  11. Make your first commit with the command git commit -m "first commit".
  12. Connect the local repository to GitHub with the command git remote add origin <URL>.
  13. Push your commit to the public repository with the command git push -u origin <branch_name>.
    • NOTE Git may prompt you for your username and password. As of 2021, this authentication method is not supported. You will need to use a Personal Access Token (PAT) instead.
      1. Go back to your GitHub homepage.
      2. Click your profile picture, then Settings, then Developer Settings.
      3. Select "Personal access tokens", then "Tokens (classic)"
      4. Click "Generate new token", then select "Generate new token (classic)".
      5. Enter a note for the token.
      6. Set an expiration date for the token.
      7. Check the checkbox next to "repo" to enable full control of repositories.
      8. Leave all other options as default, and click "Generate token".
      9. Click the copy button next to your generated token.
      10. Continue from step 13, and paste your token when prompted for a password.
        • NOTE The normal shortcut (CTRL+V) may not work in the terminal. You can use CTRL+SHIFT+V instead.
        • NOTE It may look like nothing is being entered in the password field, but it is; it is simply not being shown.
  14. Your repository is published!

My Portfolio Site

Here is a link to my public repository on GitHub for this site: github.com/CTask1/Portfolio