Skip to content

Tutorial: Basics of Github

Minh-Khang Vu edited this page Aug 15, 2019 · 2 revisions

Version Control: The Basics of Github

According to Wikipedia, Github is a "web based version control repository." In simple English, that means that Github is an online service that allows you to track and merge changes you and your teammates have made to your work. Github also allows you to do lots of other cool things, like host websites, make a Trello-like project board, and write documentation on your work.

Please note, Git is a distributed version control tool that can manage a development project's source code history, while GitHub is a cloud-based platform built around the Git tool. Git is a tool a developer installs locally on their computer, while GitHub is an online service that stores code pushed to it from computers running the Git tool. (theserverside.com)

Let’s start with the basics.

Step by step: How to save your files on Github

  1. git clone: (Only use this command the first time you want to access a repository) Copies the specified repository to your computer.

    1. git clone <insert repository URL here>

    2. git_clone

  2. git pull: Updates your local copy of the repository, on your computer.

    1. General command: git pull

    2. Pulling specific branch: ’git pull origin ’

    3. git_pull

  3. git add: Adds <filename’s> contents to the index of files being pushed to Github.

    1. Command: git add
  4. git commit: Stores all indexed files in a new commit, and tags them with a log message from the user, describing all changes.

    1. Command: git commit

    2. git_add_commit

  5. git push: Updates all remote repositories based on the files that were commited

    1. General command: git push

    2. Specific branch: `git push < remote_repository_name > < branch_name >

    3. git_push

  6. Git pull request: Lets the repository owner know that they should merge your changes with the master branch

    1. How to make a pull request: https://help.github.com/articles/creating-a-pull-request/

    2. git_pullrequest

How to push a file to Github (short version):

  1. git add <filename>

  2. git commit –m “< insert commit message >”

  3. git push origin <branchname>

Assorted Useful Git commands:

  1. git branch: Creates a new branch, or version of the code, by duplicating your current pushed version of the code. You can now work off of the code in the new branch and implement different functionality.

    1. git_branch
  2. git stash: Saves your currently commited, but not pushed, files in a “stash,” where they can later be accessed if needed. “Git Stash Apply” reverses this process.

    1. git stash < stash_name >

    2. git stash apply < stash_name >

    3. git_stash

  3. git status: Tells you what files are currently commited and will be pushed to Github.

    1. git status

References:

• Repository: The overarching location where code is stored for a project/etc.

Remote repository: Versions of your repository hosted elsewhere on the internet. They enable you to collaborate and share work with others.

• Branch: The “folder” containing a particular version of your code. You can only work on one branch at a time.

• Master branch: The branch containing the “official” version of the code. You should only push working code to the master branch, so that this version of code is functional at all times.

Merge conflict: An error that occurs when you edit the same file as someone else, then try to push your changes. Github isn’t sure which version is correct, so you must go back and manually determine which changes should be preserved.

Markdown: A “coding language” specific to Github wikis and webpages. It uses specific syntax to encode graphics.

• < Stuff >: The convention for marking user-specific input. Insert whatever “Stuff” is here. Don’t leave the “<>” signs in when executing the command.

This page is complete. This tutorial was written by L. Zuehsow, on 2-25-17.