SlideShare a Scribd company logo
Git
A Simple Introduction to
Daniel Tai, 2013
References
1. Lars Vogel, Git Tutorial
http://www.vogella.com/articles/Git/article.html

2. Atlassian, Git Tutorial
https://www.atlassian.com/git/
3. Github, Try Git yourself
http://try.github.io/
What is version control system?
Distributed version control system
What is Git?
Simply put, Git is a distributed version control
system
Local Repository Operations
Git uses "Staging" workflow
Commonly Used Commands
● Initialize a repo
○ git init
○ git clone
● Add files to staging
area
○ git add
● Creating a snapshot
○ git commit

● Un-track a file
○ git rm
● Configuring git
○ git config
● Checking status
○ git status
○ git diff
○ git log
Check here for more detailed stuffs!
https://www.atlassian.com/git/tutorial/git-basics
Before start using git…...
Setup your name and email so others can know
who committed changes:
$ git config --global user.name "<name>"
$ git config --global user.email "<email>"
Initializing a repo
● git init
○ Create a repo locally

● git clone <repo>
○ Clone another repo
○ More on this later
Staging files and Reverting changes
● git add <file>
○ Add <file> to staging area

● git reset <file>
○ Remove <file> from staging area
○ See later slides for more about git reset

● Don’t get confused with: git rm <file>
○ Untrack and delete <file>
Creating a snapshot
● git commit -m '<comment>'
○ Create a snapshot of all files in staging area
○ Always add comments, so you and others can see
what you’ve been doing
Checking Status
● git status
○ Check for status: staged files and new files

● git diff
○ Check for changes in files

● git log
○ Check commit log
Hands on Time!
Head to http://try.github.io and finish to
challenge 9
Commonly Used Commands, cont.
● Viewing previous commits
○ git checkout
● Undo a commit
○ git revert
● Unstage or revert files
○ git reset
● Delete all un-tracked files
○ git clean
Viewing previous commits
● git checkout <commit>
○ Checkout <commit>. You will be detached from
master branch.

● git checkout <commit> <file>
○ Checkout <file> in <commit> and put it into stage
area
○ Use this function to revive old version of file into new
commits
Reverting old commits
● git revert <commit>
○ Revert to <commit> and make it as a new commit
Resetting commits
● git reset <file>
○ Remove <file> from staging area
○ Does not change file content

● git reset
○ Remove all files from staging area
○ Does not change file content

● git reset has some other dangerous
functions, see here. Never use them if you
don’t fully understand it.
Working with Remote Repositories
Commands related to remote repos
● Assigning remote repository
○ git remote add <url>
● Upload local commits
○ git push
● Download remote commits
○ git pull
Working with Github
1. Apply a Github account here
(Optionally, you can upgrade to education
account here)
2. Make sure that you’ve setup your name and
email (see this slide)
3. Follow the instructions here
Connect with remote repo
● Case 1: You’ve started a local repo. You
want to push to remote repo
○ git remote add origin <url>
■ The <url> can be obtained on Github page
○ git push -u origin master

● Case 2: You are cloning other’s remote repo
○ git clone <url>
Synchronizing changes
● git pull
○ Pull (download) remote commits and merge them
into working directory
○ Merging is usually done automatically

● git push
○ Push (upload) your local commits
Hands on Time!
Back to http://try.github.io and finish to
challenge 17
Open a repo on Github and try playing around
your self
Branch and other stuff…...
Check out the references for more!

More Related Content

What's hot

Contributing to open source using Git
Contributing to open source using GitContributing to open source using Git
Contributing to open source using Git
Yan Vugenfirer
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
Priya Nayak
 
Extra bit with git
Extra bit with gitExtra bit with git
Extra bit with git
Himanshu Agrawal
 
Advance workshop on git
Advance workshop on gitAdvance workshop on git
Advance workshop on git
Himanshu Agrawal
 
Essential Git and Github commands
Essential Git and Github commandsEssential Git and Github commands
Essential Git and Github commands
Isham Rashik
 
Intro to Git
Intro to GitIntro to Git
Intro to Git
Shadab Khan
 
Git Workshop
Git WorkshopGit Workshop
Git Workshop
Agustinus Theodorus
 
Git basics
Git basicsGit basics
Git basics
Denys Haryachyy
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
DSC GVP
 
Git cheatsheet
Git cheatsheetGit cheatsheet
Git cheatsheet
synapsefre
 
Git tech talk
Git tech talkGit tech talk
Git tech talkrazasayed
 
Git basics
Git basicsGit basics
Git basics
Anthony Eli Agbenu
 
Linux GIT commands
Linux GIT commandsLinux GIT commands
Linux GIT commands
RajKumar Rampelli
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
themystic_ca
 
Github By Nyros Developer
Github By Nyros DeveloperGithub By Nyros Developer
Github By Nyros Developer
Nyros Technologies
 
Version Control Systems with git (and github) as an example
Version Control Systems with git (and github) as an exampleVersion Control Systems with git (and github) as an example
Version Control Systems with git (and github) as an example
Gaurav Kumar Garg
 
Advanced Git
Advanced GitAdvanced Git
Advanced Git
Sergiu-Ioan Ungur
 
From svn to git
From svn to gitFrom svn to git
From svn to git
Shawn Wang
 

What's hot (20)

Contributing to open source using Git
Contributing to open source using GitContributing to open source using Git
Contributing to open source using Git
 
Git presentation
Git presentationGit presentation
Git presentation
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Extra bit with git
Extra bit with gitExtra bit with git
Extra bit with git
 
Advance workshop on git
Advance workshop on gitAdvance workshop on git
Advance workshop on git
 
Git commands
Git commandsGit commands
Git commands
 
Essential Git and Github commands
Essential Git and Github commandsEssential Git and Github commands
Essential Git and Github commands
 
Intro to Git
Intro to GitIntro to Git
Intro to Git
 
Git Workshop
Git WorkshopGit Workshop
Git Workshop
 
Git basics
Git basicsGit basics
Git basics
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
 
Git cheatsheet
Git cheatsheetGit cheatsheet
Git cheatsheet
 
Git tech talk
Git tech talkGit tech talk
Git tech talk
 
Git basics
Git basicsGit basics
Git basics
 
Linux GIT commands
Linux GIT commandsLinux GIT commands
Linux GIT commands
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
 
Github By Nyros Developer
Github By Nyros DeveloperGithub By Nyros Developer
Github By Nyros Developer
 
Version Control Systems with git (and github) as an example
Version Control Systems with git (and github) as an exampleVersion Control Systems with git (and github) as an example
Version Control Systems with git (and github) as an example
 
Advanced Git
Advanced GitAdvanced Git
Advanced Git
 
From svn to git
From svn to gitFrom svn to git
From svn to git
 

Similar to A Simple Introduction to Git

Git with the flow
Git with the flowGit with the flow
Git with the flow
Dana White
 
Setting up Git.pptx
Setting up Git.pptxSetting up Git.pptx
Setting up Git.pptx
tapanvyas11
 
Intro to Git, GitHub, and BitBucket
Intro to Git, GitHub, and BitBucketIntro to Git, GitHub, and BitBucket
Techoalien git
Techoalien gitTechoalien git
Techoalien git
Aditya Tiwari
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
Aditya Tiwari
 
Git Basics 1 Carenza
Git Basics 1 CarenzaGit Basics 1 Carenza
Git Basics 1 Carenza
Peter Carenza
 
Git github
Git githubGit github
Git github
Anurag Deb
 
Git intro hands on windows with msysgit
Git intro hands on windows with msysgitGit intro hands on windows with msysgit
Git intro hands on windows with msysgit
Geshan Manandhar
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
Max Claus Nunes
 
Git basics for beginners
Git basics for beginnersGit basics for beginners
Git basics for beginners
PravallikaTammisetty
 
Git learning
Git learningGit learning
Git learning
Amit Gupta
 
Git Ninja KT (GitHub to GitLab)
Git Ninja KT (GitHub to GitLab)Git Ninja KT (GitHub to GitLab)
Git Ninja KT (GitHub to GitLab)
Ashok Kumar
 
Source Code Management with Git
Source Code Management with GitSource Code Management with Git
Source Code Management with GitThings Lab
 
How to git easily in day to-day work
How to git easily in day to-day workHow to git easily in day to-day work
How to git easily in day to-day work
Alena Radkevich
 
Collaborative development with Git | Workshop
Collaborative development with Git | WorkshopCollaborative development with Git | Workshop
Collaborative development with Git | Workshop
Anuchit Chalothorn
 
Git-r-Done
Git-r-DoneGit-r-Done
Git-r-Done
Cesar Martinez
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptually
seungzzang Kim
 
14 oct Git & GitHub.pptx
14 oct Git & GitHub.pptx14 oct Git & GitHub.pptx
14 oct Git & GitHub.pptx
GDSCGHRIETNagpur
 
Git hub abduallah abu nada
Git hub   abduallah abu nadaGit hub   abduallah abu nada
Git hub abduallah abu nada
Lama K Banna
 

Similar to A Simple Introduction to Git (20)

Git with the flow
Git with the flowGit with the flow
Git with the flow
 
Setting up Git.pptx
Setting up Git.pptxSetting up Git.pptx
Setting up Git.pptx
 
Intro to Git, GitHub, and BitBucket
Intro to Git, GitHub, and BitBucketIntro to Git, GitHub, and BitBucket
Intro to Git, GitHub, and BitBucket
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
 
Git Basics 1 Carenza
Git Basics 1 CarenzaGit Basics 1 Carenza
Git Basics 1 Carenza
 
Git github
Git githubGit github
Git github
 
Git intro hands on windows with msysgit
Git intro hands on windows with msysgitGit intro hands on windows with msysgit
Git intro hands on windows with msysgit
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
 
Git basics for beginners
Git basics for beginnersGit basics for beginners
Git basics for beginners
 
Git learning
Git learningGit learning
Git learning
 
Git Ninja KT (GitHub to GitLab)
Git Ninja KT (GitHub to GitLab)Git Ninja KT (GitHub to GitLab)
Git Ninja KT (GitHub to GitLab)
 
Source Code Management with Git
Source Code Management with GitSource Code Management with Git
Source Code Management with Git
 
How to git easily in day to-day work
How to git easily in day to-day workHow to git easily in day to-day work
How to git easily in day to-day work
 
Collaborative development with Git | Workshop
Collaborative development with Git | WorkshopCollaborative development with Git | Workshop
Collaborative development with Git | Workshop
 
Git-r-Done
Git-r-DoneGit-r-Done
Git-r-Done
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptually
 
14 oct Git & GitHub.pptx
14 oct Git & GitHub.pptx14 oct Git & GitHub.pptx
14 oct Git & GitHub.pptx
 
Git hub abduallah abu nada
Git hub   abduallah abu nadaGit hub   abduallah abu nada
Git hub abduallah abu nada
 

Recently uploaded

Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Alex Pruden
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 

Recently uploaded (20)

Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 

A Simple Introduction to Git

  • 1. Git A Simple Introduction to Daniel Tai, 2013
  • 2. References 1. Lars Vogel, Git Tutorial http://www.vogella.com/articles/Git/article.html 2. Atlassian, Git Tutorial https://www.atlassian.com/git/ 3. Github, Try Git yourself http://try.github.io/
  • 3. What is version control system?
  • 5. What is Git? Simply put, Git is a distributed version control system
  • 8. Commonly Used Commands ● Initialize a repo ○ git init ○ git clone ● Add files to staging area ○ git add ● Creating a snapshot ○ git commit ● Un-track a file ○ git rm ● Configuring git ○ git config ● Checking status ○ git status ○ git diff ○ git log
  • 9. Check here for more detailed stuffs! https://www.atlassian.com/git/tutorial/git-basics
  • 10. Before start using git…... Setup your name and email so others can know who committed changes: $ git config --global user.name "<name>" $ git config --global user.email "<email>"
  • 11. Initializing a repo ● git init ○ Create a repo locally ● git clone <repo> ○ Clone another repo ○ More on this later
  • 12. Staging files and Reverting changes ● git add <file> ○ Add <file> to staging area ● git reset <file> ○ Remove <file> from staging area ○ See later slides for more about git reset ● Don’t get confused with: git rm <file> ○ Untrack and delete <file>
  • 13. Creating a snapshot ● git commit -m '<comment>' ○ Create a snapshot of all files in staging area ○ Always add comments, so you and others can see what you’ve been doing
  • 14. Checking Status ● git status ○ Check for status: staged files and new files ● git diff ○ Check for changes in files ● git log ○ Check commit log
  • 15. Hands on Time! Head to http://try.github.io and finish to challenge 9
  • 16. Commonly Used Commands, cont. ● Viewing previous commits ○ git checkout ● Undo a commit ○ git revert ● Unstage or revert files ○ git reset ● Delete all un-tracked files ○ git clean
  • 17. Viewing previous commits ● git checkout <commit> ○ Checkout <commit>. You will be detached from master branch. ● git checkout <commit> <file> ○ Checkout <file> in <commit> and put it into stage area ○ Use this function to revive old version of file into new commits
  • 18. Reverting old commits ● git revert <commit> ○ Revert to <commit> and make it as a new commit
  • 19. Resetting commits ● git reset <file> ○ Remove <file> from staging area ○ Does not change file content ● git reset ○ Remove all files from staging area ○ Does not change file content ● git reset has some other dangerous functions, see here. Never use them if you don’t fully understand it.
  • 20. Working with Remote Repositories
  • 21. Commands related to remote repos ● Assigning remote repository ○ git remote add <url> ● Upload local commits ○ git push ● Download remote commits ○ git pull
  • 22. Working with Github 1. Apply a Github account here (Optionally, you can upgrade to education account here) 2. Make sure that you’ve setup your name and email (see this slide) 3. Follow the instructions here
  • 23. Connect with remote repo ● Case 1: You’ve started a local repo. You want to push to remote repo ○ git remote add origin <url> ■ The <url> can be obtained on Github page ○ git push -u origin master ● Case 2: You are cloning other’s remote repo ○ git clone <url>
  • 24. Synchronizing changes ● git pull ○ Pull (download) remote commits and merge them into working directory ○ Merging is usually done automatically ● git push ○ Push (upload) your local commits
  • 25. Hands on Time! Back to http://try.github.io and finish to challenge 17 Open a repo on Github and try playing around your self
  • 26. Branch and other stuff…... Check out the references for more!