SlideShare a Scribd company logo
Introduction to
git
Objective
• At the end of this session, you will be able to:
• Install git
• Create a local git repository
• Add a file to the repo
• Add a file to staging
• Create a commit
• Create a new branch
• Create a GitHub repo
• Push a branch to GitHub
Sad Story ….
Version control
• Version
control
also known as revision control
or source control, is the management of
changes to documents, computer
programs, large web sites, and other
collections of information.
• Version control systems (VCS)
Version control systems are a category of software tools that help a software team manage
changes to source code over time.
Version control software keeps track of every modification to the code in a special kind of
database.
Version control examples
Version control examples
Version control examples
Git
• Git
Git is a free and open source distributed version control
system designed to handle everything from small to very
large projects with speed and efficiency.
Git is easy to learn and has a tiny footprint with lightning
fast performance. Learn more about git here.
• Prerequisites
You will need a GitHub account
(it's free). Go to
https://github.com/join and set
up a GitHub account if you do not
have one already.
Install git
• Install git
Start by installing git on your
instance. When you're working
on your own projects, it is
always a good idea to check
for updates even if you already
have git installed. You can
install it as a package, via
another installer, or download
the source code and compile it
yourself
• Ubuntu
• Verify your installation
with the following
command:
Create a local git
repository
• Create a local git repository
Now that git is installed, create a new repository (or repo for short) to hold your release notes.
When you work on your own projects, you can create repositories in any directory you want.
1. Create a directory for your project with the mkdir (make directory) command:
• Create a local git repository
Then open the directory with the cd (change directory) command.
• Create a local git repository
Now, initialize your new git repository in the folder with the git init
command:
• Congratulations! You just initialized a git repository.
Add a file to the
repo
• Add a file to the repo
Your repository is empty. It's time to put something in it!
Add a new file to the project. You can use any text editor you like when you are
working on your own projects, but for this lab, simply create a new file with the
touch command.
Replace <file name> with a name for your file:
• Add a file to the repo
Run the ls (list) command to verify that the file was created in your project
directory:
• Add a file to the repo
Check to see which files git knows about with the git status command:
Add a file to
staging
Staging Area
Staging Area
• Add a file to staging
The next step is to add your file to the staging environment (sometimes referred
to as the index). You must do this before you commit a file. When you're
working, use the staging environment as just that - a staging ground - for
actively editing your files.
• Add a file to staging
Run the git status command again
• Notice the "Changes to be committed" line. You will see that git added
your file to the staging environment, but the file has not yet been
added to a commit.
New Branch
New Branch
Create a commit
• Create a commit
A commit is a record of what files you have changed since the last commit.
Commits allow you to go back to the state of the project at any point in history.
You create a commit in order to add files to the Master.
• Create a commit
First you need to identify yourself, then you can create the commit.
Run the following, filling in any email for "you@example.com":
• Create a commit
Run the following, filling in any name for "Your Name":
• Create a commit
Run the following git commit command. Your message should relate to what's in
your commit - for posterity:
Create a new
branch
• Create a new branch
Since you're on the master branch already, run the git checkout -b command and name
your branch. The command will:
Automatically create a new branch, using the name you specify
Immediately check the branch out to you
Move you to the new branch
• Create a new branch
• Create a new branch
Confirm that your branch was created:
Switch back to the master branch.
• Create a new branch
Make another file and add it:
• Create a new branch
Use git commit -m "Your message about the commit" to stage your changes.
Return to your branch.
Create a GitHub
repo
• Create a GitHub repo
If you're the sole owner of your project, you don't need to use GitHub. But if
you're on a team, you can use GitHub to collaborate without stepping on each
others' toes.
To create a new repo on GitHub, go to github.com and log in.
Click New repository:
• Create a
GitHub
repo
• GitHub will ask you for some basic info about your repo. Fill
out the form, then click Create repository.
• GitHub will ask you if you want to start from scratch or add a
local project. Since you just created a new repo, you want to
push that to GitHub. Follow the "...or push an existing
repository from the command line" section. Click the clipboard
to copy the commands.
• Create a GitHub repo
Return to your SSH window and run the commands you copied from GitHub.
• Create a GitHub repo
Note You will be prompted to log in. Use your GitHub credentials.
• The first command adds the local repository to your GitHub repository.
• The second command pushes your local repo to GitHub.
Push a branch to
GitHub
• Push a branch to GitHub
Pushing the commit in your branch to your new GitHub repo allows other
people to see the changes you've made (think code review). The repository's
owner can review changes prior to merging to the master branch.
Run the following command to push changes onto a new branch on GitHub,
replacing branch name with a name of your branch. Does GitHub automatically
create the branch for you on the remote repository?
• Push a branch to GitHub
• Push a branch to GitHub
In GitHub, click on the Code tab. You should now see the branch name you just pushed.
Click the Compare & pull request button that is next to your branch name.
You'll now see the name of your commit. In a production environment you could leave a
comment about this commit. For this lab click Create pull request.
GitHub verifies that the files you are adding aren't in conflict with the Master copy. If everthing
checks out, and it should since these are new files, you will see a green check mark. Click Merge
pull request, then Confirm merge.
You'll see a "Pull request successfully merged and closed" message. At this point you can click
Delete branch to clean up. You don't have to do this, but you may end up with a mess if you
have too many branches. Notice that you'll have another chance to leave comments.
Thank You

More Related Content

What's hot

Introduction to github slideshare
Introduction to github slideshareIntroduction to github slideshare
Introduction to github slideshare
Rakesh Sukumar
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
Lee Hanxue
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
Arulmurugan Rajaraman
 
Git basics
Git basicsGit basics
Git basics
GHARSALLAH Mohamed
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
Behzad Altaf
 
Git 101 for Beginners
Git 101 for Beginners Git 101 for Beginners
Git 101 for Beginners
Anurag Upadhaya
 
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overviewGit and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
Rueful Robin
 
Grokking opensource with github
Grokking opensource with githubGrokking opensource with github
Grokking opensource with github
GoogleDeveloperStude4
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
Roland Emmanuel Salunga
 
Git and Github Session
Git and Github SessionGit and Github Session
Git and Github Session
GoogleDevelopersStud1
 
Git training v10
Git training v10Git training v10
Git training v10
Skander Hamza
 
Git n git hub
Git n git hubGit n git hub
Git n git hub
Jiwon Baek
 
Introduction git
Introduction gitIntroduction git
Introduction git
Dian Sigit Prastowo
 
git and github
git and githubgit and github
git and github
Darren Oakley
 
Intro to Git and GitHub
Intro to Git and GitHubIntro to Git and GitHub
Intro to Git and GitHub
Panagiotis Papadopoulos
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
Houari ZEGAI
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
Venkat Malladi
 
Git & GitHub WorkShop
Git & GitHub WorkShopGit & GitHub WorkShop
Git & GitHub WorkShop
SheilaJimenezMorejon
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with Git
E Carter
 

What's hot (20)

Introduction to github slideshare
Introduction to github slideshareIntroduction to github slideshare
Introduction to github slideshare
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
 
Git basics
Git basicsGit basics
Git basics
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
 
Git 101 for Beginners
Git 101 for Beginners Git 101 for Beginners
Git 101 for Beginners
 
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overviewGit and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
 
Grokking opensource with github
Grokking opensource with githubGrokking opensource with github
Grokking opensource with github
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 
Git and Github Session
Git and Github SessionGit and Github Session
Git and Github Session
 
Git training v10
Git training v10Git training v10
Git training v10
 
Git n git hub
Git n git hubGit n git hub
Git n git hub
 
Introduction git
Introduction gitIntroduction git
Introduction git
 
git and github
git and githubgit and github
git and github
 
Intro to Git and GitHub
Intro to Git and GitHubIntro to Git and GitHub
Intro to Git and GitHub
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
 
Git & GitHub WorkShop
Git & GitHub WorkShopGit & GitHub WorkShop
Git & GitHub WorkShop
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with Git
 

Similar to Introduction to Git and GitHub Part 1

Version control git day02
Version control   git day02Version control   git day02
Version control git day02
Gourav Varma
 
Version control git day02
Version control   git day02Version control   git day02
Version control git day02
Gourav Varma
 
Git and Github slides.pdf
Git and Github slides.pdfGit and Github slides.pdf
Git and Github slides.pdf
Tilton2
 
Git and Github workshop ppt slide by slide
Git and Github workshop ppt slide by slideGit and Github workshop ppt slide by slide
Git and Github workshop ppt slide by slide
RaghavendraVattikuti1
 
Using git hub for your code
Using git hub for your codeUsing git hub for your code
Using git hub for your code
Osama Mustafa
 
A Tutorial for GitHub.pdf
A Tutorial for GitHub.pdfA Tutorial for GitHub.pdf
A Tutorial for GitHub.pdf
badrfathallah2
 
A Tutorial for GitHub.pdf
A Tutorial for GitHub.pdfA Tutorial for GitHub.pdf
A Tutorial for GitHub.pdf
Amarnadh36
 
Git and Github.pptx
Git and Github.pptxGit and Github.pptx
Git and Github.pptx
Hitesh670643
 
Let's Git this Party Started: An Introduction to Git and GitHub
Let's Git this Party Started: An Introduction to Git and GitHubLet's Git this Party Started: An Introduction to Git and GitHub
Let's Git this Party Started: An Introduction to Git and GitHub
Kim Moir
 
Using Git to Organize Your Project
Using Git to Organize Your ProjectUsing Git to Organize Your Project
Using Git to Organize Your Project
Manish Suwal 'Enwil'
 
Brief tutorial on Git
Brief tutorial on GitBrief tutorial on Git
Brief tutorial on Git
聖文 鄭
 
Version control git day01
Version control   git day01Version control   git day01
Version control git day01
Gourav Varma
 
Version control git day01
Version control   git day01Version control   git day01
Version control git day01
Gourav Varma
 
Git ritesh venture_pact
Git ritesh venture_pactGit ritesh venture_pact
Git ritesh venture_pact
riteshtandon23
 
Contributing to github is for everyone
Contributing to github is for everyoneContributing to github is for everyone
Contributing to github is for everyone
Matt Heusser
 
Advance workshop on git
Advance workshop on gitAdvance workshop on git
Advance workshop on git
Himanshu Agrawal
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configuration
Kishor Kumar
 
Get your Git on GitHub
Get your Git on GitHubGet your Git on GitHub
Get your Git on GitHub
Runcy Oommen
 
GDSC Git event 2023.pptx
GDSC Git event 2023.pptxGDSC Git event 2023.pptx
GDSC Git event 2023.pptx
fsxflyer789Productio
 

Similar to Introduction to Git and GitHub Part 1 (20)

Version control git day02
Version control   git day02Version control   git day02
Version control git day02
 
Version control git day02
Version control   git day02Version control   git day02
Version control git day02
 
Git and Github slides.pdf
Git and Github slides.pdfGit and Github slides.pdf
Git and Github slides.pdf
 
Git and Github workshop ppt slide by slide
Git and Github workshop ppt slide by slideGit and Github workshop ppt slide by slide
Git and Github workshop ppt slide by slide
 
Using git hub for your code
Using git hub for your codeUsing git hub for your code
Using git hub for your code
 
A Tutorial for GitHub.pdf
A Tutorial for GitHub.pdfA Tutorial for GitHub.pdf
A Tutorial for GitHub.pdf
 
A Tutorial for GitHub.pdf
A Tutorial for GitHub.pdfA Tutorial for GitHub.pdf
A Tutorial for GitHub.pdf
 
Git and Github.pptx
Git and Github.pptxGit and Github.pptx
Git and Github.pptx
 
Let's Git this Party Started: An Introduction to Git and GitHub
Let's Git this Party Started: An Introduction to Git and GitHubLet's Git this Party Started: An Introduction to Git and GitHub
Let's Git this Party Started: An Introduction to Git and GitHub
 
Using Git to Organize Your Project
Using Git to Organize Your ProjectUsing Git to Organize Your Project
Using Git to Organize Your Project
 
Brief tutorial on Git
Brief tutorial on GitBrief tutorial on Git
Brief tutorial on Git
 
16 Git
16 Git16 Git
16 Git
 
Version control git day01
Version control   git day01Version control   git day01
Version control git day01
 
Version control git day01
Version control   git day01Version control   git day01
Version control git day01
 
Git ritesh venture_pact
Git ritesh venture_pactGit ritesh venture_pact
Git ritesh venture_pact
 
Contributing to github is for everyone
Contributing to github is for everyoneContributing to github is for everyone
Contributing to github is for everyone
 
Advance workshop on git
Advance workshop on gitAdvance workshop on git
Advance workshop on git
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configuration
 
Get your Git on GitHub
Get your Git on GitHubGet your Git on GitHub
Get your Git on GitHub
 
GDSC Git event 2023.pptx
GDSC Git event 2023.pptxGDSC Git event 2023.pptx
GDSC Git event 2023.pptx
 

More from Omar Fathy

Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
Omar Fathy
 
Cloud Run and Containers
Cloud Run and ContainersCloud Run and Containers
Cloud Run and Containers
Omar Fathy
 
GitOps and ArgoCD
GitOps and ArgoCDGitOps and ArgoCD
GitOps and ArgoCD
Omar Fathy
 
DevOps! What, Why and How?
DevOps! What, Why and How?DevOps! What, Why and How?
DevOps! What, Why and How?
Omar Fathy
 
Cloud Computing
Cloud ComputingCloud Computing
Cloud Computing
Omar Fathy
 
Capture The Flag
Capture The FlagCapture The Flag
Capture The Flag
Omar Fathy
 
Google Cloud Fundamentals
Google Cloud Fundamentals Google Cloud Fundamentals
Google Cloud Fundamentals
Omar Fathy
 
Introduction to Git and GitHub Part 2
Introduction to Git and GitHub Part 2Introduction to Git and GitHub Part 2
Introduction to Git and GitHub Part 2
Omar Fathy
 

More from Omar Fathy (8)

Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Cloud Run and Containers
Cloud Run and ContainersCloud Run and Containers
Cloud Run and Containers
 
GitOps and ArgoCD
GitOps and ArgoCDGitOps and ArgoCD
GitOps and ArgoCD
 
DevOps! What, Why and How?
DevOps! What, Why and How?DevOps! What, Why and How?
DevOps! What, Why and How?
 
Cloud Computing
Cloud ComputingCloud Computing
Cloud Computing
 
Capture The Flag
Capture The FlagCapture The Flag
Capture The Flag
 
Google Cloud Fundamentals
Google Cloud Fundamentals Google Cloud Fundamentals
Google Cloud Fundamentals
 
Introduction to Git and GitHub Part 2
Introduction to Git and GitHub Part 2Introduction to Git and GitHub Part 2
Introduction to Git and GitHub Part 2
 

Recently uploaded

FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 

Recently uploaded (20)

FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 

Introduction to Git and GitHub Part 1

  • 2. Objective • At the end of this session, you will be able to: • Install git • Create a local git repository • Add a file to the repo • Add a file to staging • Create a commit • Create a new branch • Create a GitHub repo • Push a branch to GitHub
  • 4.
  • 6. • Version control also known as revision control or source control, is the management of changes to documents, computer programs, large web sites, and other collections of information.
  • 7. • Version control systems (VCS) Version control systems are a category of software tools that help a software team manage changes to source code over time. Version control software keeps track of every modification to the code in a special kind of database.
  • 11. Git
  • 12. • Git Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Git is easy to learn and has a tiny footprint with lightning fast performance. Learn more about git here.
  • 13. • Prerequisites You will need a GitHub account (it's free). Go to https://github.com/join and set up a GitHub account if you do not have one already.
  • 15. • Install git Start by installing git on your instance. When you're working on your own projects, it is always a good idea to check for updates even if you already have git installed. You can install it as a package, via another installer, or download the source code and compile it yourself
  • 17. • Verify your installation with the following command:
  • 18. Create a local git repository
  • 19. • Create a local git repository Now that git is installed, create a new repository (or repo for short) to hold your release notes. When you work on your own projects, you can create repositories in any directory you want. 1. Create a directory for your project with the mkdir (make directory) command:
  • 20. • Create a local git repository Then open the directory with the cd (change directory) command.
  • 21. • Create a local git repository Now, initialize your new git repository in the folder with the git init command: • Congratulations! You just initialized a git repository.
  • 22. Add a file to the repo
  • 23. • Add a file to the repo Your repository is empty. It's time to put something in it! Add a new file to the project. You can use any text editor you like when you are working on your own projects, but for this lab, simply create a new file with the touch command. Replace <file name> with a name for your file:
  • 24. • Add a file to the repo Run the ls (list) command to verify that the file was created in your project directory:
  • 25. • Add a file to the repo Check to see which files git knows about with the git status command:
  • 26. Add a file to staging
  • 29. • Add a file to staging The next step is to add your file to the staging environment (sometimes referred to as the index). You must do this before you commit a file. When you're working, use the staging environment as just that - a staging ground - for actively editing your files.
  • 30. • Add a file to staging Run the git status command again • Notice the "Changes to be committed" line. You will see that git added your file to the staging environment, but the file has not yet been added to a commit.
  • 34. • Create a commit A commit is a record of what files you have changed since the last commit. Commits allow you to go back to the state of the project at any point in history. You create a commit in order to add files to the Master.
  • 35. • Create a commit First you need to identify yourself, then you can create the commit. Run the following, filling in any email for "you@example.com":
  • 36. • Create a commit Run the following, filling in any name for "Your Name":
  • 37. • Create a commit Run the following git commit command. Your message should relate to what's in your commit - for posterity:
  • 39. • Create a new branch Since you're on the master branch already, run the git checkout -b command and name your branch. The command will: Automatically create a new branch, using the name you specify Immediately check the branch out to you Move you to the new branch
  • 40. • Create a new branch
  • 41. • Create a new branch Confirm that your branch was created: Switch back to the master branch.
  • 42. • Create a new branch Make another file and add it:
  • 43. • Create a new branch Use git commit -m "Your message about the commit" to stage your changes. Return to your branch.
  • 45. • Create a GitHub repo If you're the sole owner of your project, you don't need to use GitHub. But if you're on a team, you can use GitHub to collaborate without stepping on each others' toes. To create a new repo on GitHub, go to github.com and log in. Click New repository:
  • 46. • Create a GitHub repo • GitHub will ask you for some basic info about your repo. Fill out the form, then click Create repository. • GitHub will ask you if you want to start from scratch or add a local project. Since you just created a new repo, you want to push that to GitHub. Follow the "...or push an existing repository from the command line" section. Click the clipboard to copy the commands.
  • 47. • Create a GitHub repo Return to your SSH window and run the commands you copied from GitHub.
  • 48. • Create a GitHub repo Note You will be prompted to log in. Use your GitHub credentials. • The first command adds the local repository to your GitHub repository. • The second command pushes your local repo to GitHub.
  • 49. Push a branch to GitHub
  • 50. • Push a branch to GitHub Pushing the commit in your branch to your new GitHub repo allows other people to see the changes you've made (think code review). The repository's owner can review changes prior to merging to the master branch. Run the following command to push changes onto a new branch on GitHub, replacing branch name with a name of your branch. Does GitHub automatically create the branch for you on the remote repository?
  • 51. • Push a branch to GitHub
  • 52. • Push a branch to GitHub In GitHub, click on the Code tab. You should now see the branch name you just pushed. Click the Compare & pull request button that is next to your branch name. You'll now see the name of your commit. In a production environment you could leave a comment about this commit. For this lab click Create pull request. GitHub verifies that the files you are adding aren't in conflict with the Master copy. If everthing checks out, and it should since these are new files, you will see a green check mark. Click Merge pull request, then Confirm merge. You'll see a "Pull request successfully merged and closed" message. At this point you can click Delete branch to clean up. You don't have to do this, but you may end up with a mess if you have too many branches. Notice that you'll have another chance to leave comments.