0% found this document useful (0 votes)
2 views

Git Github Intro

This document provides an introduction to Git and GitHub, explaining Git as a version control system that tracks changes in collaborative projects and GitHub as a platform for hosting Git repositories. It outlines essential Git terminology, setup instructions, and the process for creating and managing repositories on GitHub, including adding, committing, and pushing changes. The document also includes a demo to practice creating a repository and making changes to files within it.

Uploaded by

voebio
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Git Github Intro

This document provides an introduction to Git and GitHub, explaining Git as a version control system that tracks changes in collaborative projects and GitHub as a platform for hosting Git repositories. It outlines essential Git terminology, setup instructions, and the process for creating and managing repositories on GitHub, including adding, committing, and pushing changes. The document also includes a demo to practice creating a repository and making changes to files within it.

Uploaded by

voebio
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Meeting #4

Introduction to Git & Github


What is Git?
● Git is a Version Control System, which basically means that it is a software
tool that tracks changes made to code and files in a collaborative project.
● Why should we use it? Git provides a comprehensive record of changes
made by different contributors over time. Some benefits include: facilitates
collaboration, improves code quality, and enables easy rollback to previous
versions.
● Think of it like shared google docs for code, where you can see all changes,
roll back changes, and see who made changes and why
What is Github?
● Github is a web-based platform for Git repository hosting
● Github also provides tools for managing project development workflows, such
as issues, pull requests, and code reviews
● It enables collaboration among developers by allowing them to work on the
same codebase simultaneously and review each other's work
● Github also offers features such as project management, continuous
integration and deployment, and team collaboration tools
● You will need knowledge of Git & Github for almost anything that you will do in
the field of computer science
Git terminology
● Repository (repo): A project folder containing code, files, and their version
history
● Commit: A snapshot of changes made to a repo at a certain point in time
● Branch: A parallel version of a repo, used for working on new features or fixes
without affecting the main branch
● Merge: The process of combining changes from one branch into another

Install Git at: https://git-scm.com/downloads


Git setup
● Step 1: Open a terminal or command prompt on your computer.
● Step 2: Configure your name and email address with the following commands:
git config --global user.name "Your Name"

git config --global user.email "[email protected]"

Check that it worked by running: git config --list


You should see:
Why do the previous setup?
● This information is used to identify who made changes to the codebase in the
version control system.
● The --global flag sets these values as the default for all repositories on your
computer.
● This step is crucial for properly attributing changes and enabling collaboration
with other contributors in the Git repository.
Creating a local repository
● Step 1: Navigate to your project folder in the terminal or command prompt.
This code makes a new folder called gitdemo (this
can be any name you want but don’t make it
standalone things such as “git” for example.

The second command changes the directory to the


newly made gitdemo folder

● Step 2: Initialize a new Git repository with the command git init:

Important thing to note that the directory changes


when doing cd directoryname
Adding and committing changes
● Step 1: Make changes to your project files as needed.
● Step 2: Add changes to the staging area with the command: git add .
This adds all changes in the current directory and
its subdirectories to the staging area. You can also
specify individual files/directories to add.

● Step 3: Commit the changes with the command: git commit -m "Your commit
message"

You can see your message by going into the gitdemo folder, into .git, and looking at
the COMMIT_EDITMSG file:
Branches
● Step 1: Create a new branch with the command:

git checkout -b your-new-branch-name


This command creates a new branch in Git with the specified name and switches to that branch.
This allows you to work on new features or changes without affecting the main codebase.

● Switch between branches with the command: git checkout branch-name


● Merge changes from one branch into another with the command: git merge
source-branch-name
● The above two lines can be better visualized when used in an actual project,
so don’t worry about writing them for this demo
Github setup
● Step 1: Visit https://github.com/ in your web browser.
● Step 2: Sign up for a free account by clicking on the "Sign up" button on the
homepage and following the prompts.
● Step 3: Verify your email address by clicking on the verification link sent to the
email address you used to sign up.

Setting up a GitHub account is essential for collaborating with others on software


projects, hosting your code online, and contributing to open-source projects. Once
you have created an account, you can start creating repositories and collaborating
with other users on GitHub. We will be using this resource for the RF part of the
project that we will begin today
How to create your own Github Repository
● Step 1: Click the "+" icon in the top right corner of your GitHub homepage.
● Step 2: Select "New repository" from the drop-down menu.
● Step 3: Choose a repository name and specify whether you want it to be public
or private.
● Step 4: Initialize the repository with a README file.
● Step 5: Click "Create repository" to create the new repository.

Creating a GitHub repository enables you to host your code online and collaborate
with others. Once you have created a repository, you can add files to it, make
changes, and collaborate with others by sharing the repository's URL. You can also
add collaborators to your repository to enable them to work on the project with you.
Connecting to a Github Repository
● Step 1: Go to your GitHub repository page and locate the HTTPS URL for the
repository.
● Step 2: Copy the repository's HTTPS URL to your clipboard.
● Step 3: Open your terminal and navigate to your local repository.
● Step 4: Add the remote repository with the command: git remote add origin
repositoryurl. Authenticate via the browser.
Pushing and pulling changes
● To push a local change to GitHub, use the command: git push origin branch-
name
● To pull changes from GitHub to your local repository, use the command: git
pull origin branch-name

Pushing and pulling changes is a fundamental aspect of collaborating on software


projects with Git and GitHub. By pushing your changes to the remote repository,
you can enable others to view and collaborate on your code. Pulling changes from
the remote repository enables you to keep your local repository up-to-date with the
latest changes made by others.
Demo of what we learned
1) Make your own repository on github.
2) On the next page, click on “Add file” and select “Create new file”
3) Name the file something like “demo.txt”
4) In the “Edit new file” section, enter any text such as “I like demos”
5) Scroll down and click on “Commit new file”
6) Use the command: git clone https://github.com/your-username/reponame
7) Navigate to the directory where we cloned it with: cd reponame
8) Open the demo.txt file with file explorer and change the text to something
like “I like changing text” and save it
9) Add all the changes to the staging area by running: git add .
10)Commit the changes with: git commit -m "Changed I like demos to I like
changing text"
11) Push your changes to the main branch with: git push origin main

You might also like