Skip to content

TenghuiZhang/GitWorkshops

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitWorkshops

Welcome to our GitHub workshop. Get ready to learn all about the basics of using GitHub. Below are list of useful links and commands that we'll be using throughout this workshop. If you'd like to see our full presentation click here

Pre Test

Before you start, you should've completed the pre-workshop survey shown in the presentation.

Set Up

Begin by

  1. Git Installation Instructions
  2. Creat your GitHub account

Basic Linux Commands

These are some Linux commands that you'll might need in your terminal (/Git Bash - which you've just downloaded)

   ls shows files and folders (aka directories)
   mkdir <folder_name> makes a new directory
   cd <directory_path> changes directory to the specified path
   touch <file_name> used to update access date of file/directory
   cp <file_name> <new_file> copies contents of <file_name> to <new_file>
   mv <file_name> <new_file> moves <file_name> and it's contents to another location/name
   rm [-rf] <file_name> removes file (-rf tag removes folders and their contents, recursively)

Basic Git

Forking is a GitHub feature that creates a copy of some repository into a specified account that you have access to. Begin by going to that repository's web page.

  1. Fork to your personal account by clicking the "Fork" button in the upper right hand corner.
  2. Invite your teammates to join your forked repository by going to the "Settings" page of the repository.
  3. Select the "Collaborators" tab from the sidebar on the left and enter your teammates' usernames.

Copies a GitHub Repo from GitHub onto your computer. This creates the working directory, staging area, and Git Repo for you, so you don't need to init.

Copy the HTTPS URL from the repository. Before you use this URL, be sure to change to the directory where you'd like for the repository to be saved on your local machine. The sequence of events

cd git-repos/
git clone <url>

Now it is on your local machine. See for yourself by using the ls command!

Displays the working tree's status.

git status

Red changes are not staged for commit, whereas green changes are staged for commit.

Uploading to Your Repository

In general, the basic flow of updating the repository based on your changes is to add, commit, and push.

git add .
git commit -m "A descriptive message"
git push

This is how you can unstage files that have been staged for a commit.

git reset .

Pulling updates your local machine with the latest changes made to the remote repository.

git pull

If you are given an error when attempting to git push, often times the error is because your local repository is not up to date which can be solved by git pull. However, if you pull and run across a CONFLICT message you'll need to open the file with the conflict and resolve them.

Code that is between the <<<<<<< HEAD and ======= are changes that you've made.
Code between the ======= and >>>>>>> <commit_id> is what is located in the remote repository.

For example, your code might look like this:

<<<<<<< HEAD
Changes you've made.
=======
What exists on the remote git repository.
>>>>>>> <commit_id>

Simply delete the conflict markers and the line you don't need (or don't delete either line if you'd like to keep both).

Post Test

When you finsh, you should completed the post-workshop survey shown in the presentation.

Initializes a non-git directory into a git repository.
It does NOT automatically put itself onto GitHub.

First, create a directory that you'd like to turn into a git repository. Change to that directory and make some files. Finally, initalize the directory into a git repository!

mkdir example-folder      # Creates a directory
cd example-folder         # Changes into that directory
touch random-file.txt     # Creates a random .txt file
git init                  # Initializes this directory into a Git Repository

For your local Git repository to exist on GitHub you have to go the GitHub's website and create a new repository. On the GitHub homepage, click the "New repository" button on the lower right hand corner. Copy the URL from this new repository to use in the following commands:

git remote add origin <url>
git push --set-upstream origin master

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%