SlideShare una empresa de Scribd logo
1 de 26
Git
A f r e e a n d o p e n s o u r c e
d i s t r i b u t e d v e r s i o n c o n t r o l s y s t e m
What does Git do?
Git allows group of people to work on the same documents at the same time, and
without stepping on each other’s toes. This is called distributed Version Control and
source code management System (VCS).
Git handles from small to large projects with speed and efficiency. Overall, Git is a free
software distributed under the terms of the GNU General Public License version 2.
Benefits of Version Control
System
VCS has following benefits:
1. It allows developers to work simultaneously,
2. It does not allow overwriting each other’s changes and,
3. It maintains a history of every version.
In following slides, we will learn about the advantages and some of the basic commands
of Git. Let’s learn it.
Advantages of Git
Here is the list of advantages that is why Git becomes so popular. Because,
1. it is Free and Open Source,
2. it is Fast and small,
3. it provides Implicit backup,
4. it is Secured and,
5. it has Easier branching.
Basic Git commands
Now, after getting through advantages, let’s go through some of its commands that we use generally.
Here is the list:
1. git init
2. git status
3. git add
4. git commit
5. git log
6. git remote
7. git push
8. git pull
9. git diff
10. git reset
11. git checkout
12. git branch and
13. git merge
git init
Use to initialize an empty Git repository located in your local system.
git status
Use to see the current status of the project.
Often, this command is used to see the progress of the project and to check how is
things going on. Lest, something has happened erroneously or unknowingly and we
have no knowledge about this. So, this command gives us the update of the repository
like what file(s) has been added, removed or edited.
git add <file name>
Use to add file(s) to the staging area to start tracking changes made to these files. At
staging area, we can add or remove files before storing them in our repository.
We can specify particular file format to stage or add all files at once to the staging area by
using last two commands.
Other usage of this commands is listed below:
git add ‘*.txt’
or,
git add .
git commit
This command is used to store the staged changes in our repository. Here, you can add a
message describing what you’ve changed.
Usage:
git commit -m “type your message”
git log
This command is used to see a report of changes committed to the repository.
Usage:
git log
git log --oneline
git log --oneline –graph
and much more.
git remote add <option>
This command is used to push our local repository to a remote repository on GitHub
server.
For this, we have to first create a new empty GitHub repository. Its path may look like -
“https://github.com/<repo folder name>/<repo name>.git
For example:
Let us say, <repo folder name> is “gitrepo” and <repo name> is “my_repo”, then the
complete command would be as below:
$ git remote add origin https://github.com/gitrepo/my_repo.git
git push
The push command tells Git where to put our commits when we need to do so.
Here, the name of our remote is ‘origin’ and the default local branch name is ‘mybranch’. The -u tells Git
to remember the parameters, so that next time we can simply run ‘git push’ and Git will know what to do.
Usage:
git push -u origin mybranch
On success, following message will appear:
“Branch master set up to track remote branch master from origin.”
git pull
The pull command helps us to update our local repo with the changes made by other
people on our GitHub repository. So, to check for changes and pull down any new
changes, we can use this command.
Usage:
git pull
git diff head
Now, we want to see the difference between our last and current commits.
Usage:
git diff head
git diff --staged
This command shows differences between two files at staging area.
git reset <file name>
To unstage our last commit, we use ‘reset’ command.
git checkout --<branch name>
Files can be changed back to how they were at the last commit by using this command.
Usage:
git checkout <branch name>
git branch
To create a copy of the master branch, we use this command. Then when we are done
with the new changes, we can merge this copied branch back into its main ‘master’
branch.
Usage:
git branch clean_up
Branch switching
Now, we have two local branches: a main branch named ‘master’ and our new branch
named ‘clean_up’. We can switch branches using following command.
Usage:
$ git checkout clean_up
[Removing unwanted files]
$ git rm <file name>
Since, we have merged the changes into the master branch. Now, we do not need files in
our local branch. Therefore, we can remove these files. This not only remove the actual
files from disk, but also stage the removal of the files for us. For this, we use following
command:
$ git rm *.txt
We can use ‘wildcard’ character i.e. *, to include all relevant files.
[Committing the changes]
$ git commit -m <message>
Since, we have removed all the files and now need to commit these changes into the
master branch. So, the command line will look like –
Usage:
$ git commit -m “Remove all the cats”
[Checking out]
$ git checkout master
We need to switch back to ‘master’ branch to merge changes done in other branch i.e.
clean_up.
[Merging]
$ git merge <branch name>
Now, we need to merge changes into the “master” branch. Since, we are already in
“master” branch. Therefore, we just need to merge “clean_up” branch into “master”
branch. Here is the merging command:
Usage:
$ git merge clean_up
[Cleaning up the things]
$ git branch -d <branch name>
In our last attempt, we have merged the branch successfully. Now, we are done with the
“clean_up” branch we do not need this anymore. So, the command to delete a branch is
given below:
$ git branch -d clean_up
[Final thing to do]
$ git push
Now, everything has been cleaned up. Final step is to push everything on to our remote
repository. Use this command and we are done. That’s it.
Happy Learning!

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Git commands
Git commandsGit commands
Git commands
 
Git 101
Git 101Git 101
Git 101
 
Version Control History and Git Basics
Version Control History and Git BasicsVersion Control History and Git Basics
Version Control History and Git Basics
 
Gitting out of trouble
Gitting out of troubleGitting out of trouble
Gitting out of trouble
 
Git in 10 minutes
Git in 10 minutesGit in 10 minutes
Git in 10 minutes
 
01 - Git vs SVN
01 - Git vs SVN01 - Git vs SVN
01 - Git vs SVN
 
A Practical Introduction to git
A Practical Introduction to gitA Practical Introduction to git
A Practical Introduction to git
 
Introduction To Git
Introduction To GitIntroduction To Git
Introduction To Git
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Git and GitHub workflows
Git and GitHub workflowsGit and GitHub workflows
Git and GitHub workflows
 
From svn to git
From svn to gitFrom svn to git
From svn to git
 
Git basics
Git basicsGit basics
Git basics
 
An Introduction to Git
An Introduction to GitAn Introduction to Git
An Introduction to Git
 
Git tutorial II
Git tutorial IIGit tutorial II
Git tutorial II
 
Learning git
Learning gitLearning git
Learning git
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Introduction to git & GitHub
Introduction to git & GitHubIntroduction to git & GitHub
Introduction to git & GitHub
 

Destacado

Getting Git Right
Getting Git RightGetting Git Right
Getting Git RightSven Peters
 
Advanced Git
Advanced GitAdvanced Git
Advanced Gitsegv
 
Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners HubSpot
 
Git 101 Presentation
Git 101 PresentationGit 101 Presentation
Git 101 PresentationScott Chacon
 
Git and Git Workflow Models as Catalysts of Software Development
Git and Git Workflow Models as Catalysts of Software DevelopmentGit and Git Workflow Models as Catalysts of Software Development
Git and Git Workflow Models as Catalysts of Software DevelopmentLemi Orhan Ergin
 
初心者 Git 上手攻略
初心者 Git 上手攻略初心者 Git 上手攻略
初心者 Git 上手攻略Lucien Lee
 
[NDC16] Effective Git
[NDC16] Effective Git[NDC16] Effective Git
[NDC16] Effective GitChanwoong Kim
 
寫給大家的 Git 教學
寫給大家的 Git 教學寫給大家的 Git 教學
寫給大家的 Git 教學littlebtc
 
Introduction to Git/Github - A beginner's guide
Introduction to Git/Github - A beginner's guideIntroduction to Git/Github - A beginner's guide
Introduction to Git/Github - A beginner's guideRohit Arora
 
Git-ing out of your git messes
Git-ing out of  your git messesGit-ing out of  your git messes
Git-ing out of your git messesKatie Sylor-Miller
 
Git基礎介紹
Git基礎介紹Git基礎介紹
Git基礎介紹Max Ma
 
ECG - 1 Toward the Basics
ECG - 1 Toward the Basics ECG - 1 Toward the Basics
ECG - 1 Toward the Basics MNDU net
 
Android studio & Git in Windows
Android studio & Git in WindowsAndroid studio & Git in Windows
Android studio & Git in WindowsPin-Lun Huang
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to gitBo-Yi Wu
 

Destacado (20)

Getting Git Right
Getting Git RightGetting Git Right
Getting Git Right
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
 
Git Tutorial 教學
Git Tutorial 教學Git Tutorial 教學
Git Tutorial 教學
 
Advanced Git
Advanced GitAdvanced Git
Advanced Git
 
Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners
 
Git 101 Presentation
Git 101 PresentationGit 101 Presentation
Git 101 Presentation
 
Git and Git Workflow Models as Catalysts of Software Development
Git and Git Workflow Models as Catalysts of Software DevelopmentGit and Git Workflow Models as Catalysts of Software Development
Git and Git Workflow Models as Catalysts of Software Development
 
Git and Github
Git and GithubGit and Github
Git and Github
 
初心者 Git 上手攻略
初心者 Git 上手攻略初心者 Git 上手攻略
初心者 Git 上手攻略
 
[NDC16] Effective Git
[NDC16] Effective Git[NDC16] Effective Git
[NDC16] Effective Git
 
寫給大家的 Git 教學
寫給大家的 Git 教學寫給大家的 Git 教學
寫給大家的 Git 教學
 
Introduction to Git/Github - A beginner's guide
Introduction to Git/Github - A beginner's guideIntroduction to Git/Github - A beginner's guide
Introduction to Git/Github - A beginner's guide
 
Getting Git
Getting GitGetting Git
Getting Git
 
Git Branching Model
Git Branching ModelGit Branching Model
Git Branching Model
 
Git-ing out of your git messes
Git-ing out of  your git messesGit-ing out of  your git messes
Git-ing out of your git messes
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Git基礎介紹
Git基礎介紹Git基礎介紹
Git基礎介紹
 
ECG - 1 Toward the Basics
ECG - 1 Toward the Basics ECG - 1 Toward the Basics
ECG - 1 Toward the Basics
 
Android studio & Git in Windows
Android studio & Git in WindowsAndroid studio & Git in Windows
Android studio & Git in Windows
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
 

Similar a Git learning

Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?9 series
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubDSC GVP
 
git github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptxgit github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptxAbelPhilipJoseph
 
git-commands-cheat-sheet-infopediya-com.pdf
git-commands-cheat-sheet-infopediya-com.pdfgit-commands-cheat-sheet-infopediya-com.pdf
git-commands-cheat-sheet-infopediya-com.pdfmurad khan
 
Git, Docker, Python Package and Module
Git, Docker, Python Package and ModuleGit, Docker, Python Package and Module
Git, Docker, Python Package and ModuleNovita Sari
 
Git Memento of basic commands
Git Memento of basic commandsGit Memento of basic commands
Git Memento of basic commandsZakaria Bouazza
 
Checkitmobile advanced git
Checkitmobile advanced gitCheckitmobile advanced git
Checkitmobile advanced gitGerrit Wanderer
 
Advanced Web Development in PHP - Code Versioning and Branching with Git
Advanced Web Development in PHP - Code Versioning and Branching with GitAdvanced Web Development in PHP - Code Versioning and Branching with Git
Advanced Web Development in PHP - Code Versioning and Branching with GitRasan Samarasinghe
 

Similar a Git learning (20)

Git github
Git githubGit github
Git github
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Git basics for beginners
Git basics for beginnersGit basics for beginners
Git basics for beginners
 
Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
 
Git introduction
Git introductionGit introduction
Git introduction
 
GIT_Overview.
GIT_Overview.GIT_Overview.
GIT_Overview.
 
git github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptxgit github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptx
 
git-commands-cheat-sheet-infopediya-com.pdf
git-commands-cheat-sheet-infopediya-com.pdfgit-commands-cheat-sheet-infopediya-com.pdf
git-commands-cheat-sheet-infopediya-com.pdf
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Formation git
Formation gitFormation git
Formation git
 
Git and Github
Git and GithubGit and Github
Git and Github
 
Github By Nyros Developer
Github By Nyros DeveloperGithub By Nyros Developer
Github By Nyros Developer
 
Git and github
Git and githubGit and github
Git and github
 
Git, Docker, Python Package and Module
Git, Docker, Python Package and ModuleGit, Docker, Python Package and Module
Git, Docker, Python Package and Module
 
Git Memento of basic commands
Git Memento of basic commandsGit Memento of basic commands
Git Memento of basic commands
 
Learn Git Basics
Learn Git BasicsLearn Git Basics
Learn Git Basics
 
Checkitmobile advanced git
Checkitmobile advanced gitCheckitmobile advanced git
Checkitmobile advanced git
 
Advanced Web Development in PHP - Code Versioning and Branching with Git
Advanced Web Development in PHP - Code Versioning and Branching with GitAdvanced Web Development in PHP - Code Versioning and Branching with Git
Advanced Web Development in PHP - Code Versioning and Branching with Git
 
GIT By Sivakrishna
GIT By SivakrishnaGIT By Sivakrishna
GIT By Sivakrishna
 

Último

BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Best Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfBest Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfIdiosysTechnologies1
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 

Último (20)

BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Best Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfBest Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdf
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 

Git learning

  • 1. Git A f r e e a n d o p e n s o u r c e d i s t r i b u t e d v e r s i o n c o n t r o l s y s t e m
  • 2. What does Git do? Git allows group of people to work on the same documents at the same time, and without stepping on each other’s toes. This is called distributed Version Control and source code management System (VCS). Git handles from small to large projects with speed and efficiency. Overall, Git is a free software distributed under the terms of the GNU General Public License version 2.
  • 3. Benefits of Version Control System VCS has following benefits: 1. It allows developers to work simultaneously, 2. It does not allow overwriting each other’s changes and, 3. It maintains a history of every version. In following slides, we will learn about the advantages and some of the basic commands of Git. Let’s learn it.
  • 4. Advantages of Git Here is the list of advantages that is why Git becomes so popular. Because, 1. it is Free and Open Source, 2. it is Fast and small, 3. it provides Implicit backup, 4. it is Secured and, 5. it has Easier branching.
  • 5. Basic Git commands Now, after getting through advantages, let’s go through some of its commands that we use generally. Here is the list: 1. git init 2. git status 3. git add 4. git commit 5. git log 6. git remote 7. git push 8. git pull 9. git diff 10. git reset 11. git checkout 12. git branch and 13. git merge
  • 6. git init Use to initialize an empty Git repository located in your local system.
  • 7. git status Use to see the current status of the project. Often, this command is used to see the progress of the project and to check how is things going on. Lest, something has happened erroneously or unknowingly and we have no knowledge about this. So, this command gives us the update of the repository like what file(s) has been added, removed or edited.
  • 8. git add <file name> Use to add file(s) to the staging area to start tracking changes made to these files. At staging area, we can add or remove files before storing them in our repository. We can specify particular file format to stage or add all files at once to the staging area by using last two commands. Other usage of this commands is listed below: git add ‘*.txt’ or, git add .
  • 9. git commit This command is used to store the staged changes in our repository. Here, you can add a message describing what you’ve changed. Usage: git commit -m “type your message”
  • 10. git log This command is used to see a report of changes committed to the repository. Usage: git log git log --oneline git log --oneline –graph and much more.
  • 11. git remote add <option> This command is used to push our local repository to a remote repository on GitHub server. For this, we have to first create a new empty GitHub repository. Its path may look like - “https://github.com/<repo folder name>/<repo name>.git For example: Let us say, <repo folder name> is “gitrepo” and <repo name> is “my_repo”, then the complete command would be as below: $ git remote add origin https://github.com/gitrepo/my_repo.git
  • 12. git push The push command tells Git where to put our commits when we need to do so. Here, the name of our remote is ‘origin’ and the default local branch name is ‘mybranch’. The -u tells Git to remember the parameters, so that next time we can simply run ‘git push’ and Git will know what to do. Usage: git push -u origin mybranch On success, following message will appear: “Branch master set up to track remote branch master from origin.”
  • 13. git pull The pull command helps us to update our local repo with the changes made by other people on our GitHub repository. So, to check for changes and pull down any new changes, we can use this command. Usage: git pull
  • 14. git diff head Now, we want to see the difference between our last and current commits. Usage: git diff head
  • 15. git diff --staged This command shows differences between two files at staging area.
  • 16. git reset <file name> To unstage our last commit, we use ‘reset’ command.
  • 17. git checkout --<branch name> Files can be changed back to how they were at the last commit by using this command. Usage: git checkout <branch name>
  • 18. git branch To create a copy of the master branch, we use this command. Then when we are done with the new changes, we can merge this copied branch back into its main ‘master’ branch. Usage: git branch clean_up
  • 19. Branch switching Now, we have two local branches: a main branch named ‘master’ and our new branch named ‘clean_up’. We can switch branches using following command. Usage: $ git checkout clean_up
  • 20. [Removing unwanted files] $ git rm <file name> Since, we have merged the changes into the master branch. Now, we do not need files in our local branch. Therefore, we can remove these files. This not only remove the actual files from disk, but also stage the removal of the files for us. For this, we use following command: $ git rm *.txt We can use ‘wildcard’ character i.e. *, to include all relevant files.
  • 21. [Committing the changes] $ git commit -m <message> Since, we have removed all the files and now need to commit these changes into the master branch. So, the command line will look like – Usage: $ git commit -m “Remove all the cats”
  • 22. [Checking out] $ git checkout master We need to switch back to ‘master’ branch to merge changes done in other branch i.e. clean_up.
  • 23. [Merging] $ git merge <branch name> Now, we need to merge changes into the “master” branch. Since, we are already in “master” branch. Therefore, we just need to merge “clean_up” branch into “master” branch. Here is the merging command: Usage: $ git merge clean_up
  • 24. [Cleaning up the things] $ git branch -d <branch name> In our last attempt, we have merged the branch successfully. Now, we are done with the “clean_up” branch we do not need this anymore. So, the command to delete a branch is given below: $ git branch -d clean_up
  • 25. [Final thing to do] $ git push Now, everything has been cleaned up. Final step is to push everything on to our remote repository. Use this command and we are done. That’s it.