SlideShare une entreprise Scribd logo
1  sur  21
Télécharger pour lire hors ligne
Content
1. Introduction
2. Git overview
3. Basic git command
4. Git tools
5. Hopee git workflow
Introduction
´Distributed Version Control System (DVCS)
´Free opensource (inspired from BitKeeper)
´Original author: Author Linus Torvald
´Initial release 7 April 2005; 13 years ago
´Current mainter Junio Hamano (gitter) Google engineer
Overview - CVC vs DVS
Overview - Concept
1. Git thinks about its data more like a stream of snapshots.
Commit, or save the state it basically takes a picture of what all your files look like at that
moment and stores a reference to that snapshot
Overview - concept
1. Integrity - Nearly Every Operation Is Local
Everything in Git is check-summed before it is stored and is then referred to by that
checksum.
2. Git Generally Only Adds Data
When you do actions in Git, nearly all of them only add data to the Git database
Overviews – Local operations
File lifecycle
Git basic – SSH
https://help.github.com/articles/generating-a-new-ssh-key-
and-adding-it-to-the-ssh-agent/#generating-a-new-ssh-key
1. Shell Secure on TCP/IP
Git basic
1. Install
2. Clone new project
3. Git config
# ubuntu
sudo apt-get install git
# centos
yum install git
# Macos
brew install git
# public repo not require ssh key
git clone git@github.com:jwasham/coding-interview-university.git
# public repo not require user/password
git clone https://github.com/jwasham/coding-interview-university.git
# config for local (--local). For global (--global)
git config --local user.name 'kan kan’
git config --local user.email ’buikhanh.bk@gmail.com’
Git basic
3. Init local repo
4. Push to git server
git init
git add LICENSE.md README.md
# add all file (not recommend when working)
git add .
# commit to git at local
git commit –m ‘init project’
# list remote link to server
git remote –v
# add 1 link to git repo. Usually using origin
git remote add origin git@github.com:1Rhino/coding-interview-university.git
# add another git remote link
git remote add hopee git@github.com:1Rhino/coding-interview-university.git
# push to server git
git push origin master (git push hopee master)
Git basic
5. create branch
6. Pull data
# create new branch develop
git branch develop
# jump to branch develop
git checkout develop
# create new branch and jump to it (ussually)
git checkout –b develop
# fetch data from server to local but not merge
git fetch origin develop
# merge data from branch develop to master (current branch: master)
git merge develop
# fetch data from server and merge to current branch
git pull origin develop
Git basic
Data tranfer flow
Git basic
Git conflict when merge (pull)
Git basic
7. Status
git status
git diff file_name.rb folder_name
git difftool file_name.rb folder_name
# add file, folder to stage
git add file_name.rb folder_name
# reset from stage -> modified
git reset file_name.rb folder_name
# discard change
git checkout file_name.rb folder_name
Git basic
8. History
9. Ignore
# list history commit
git log
git log --pretty="%h - %s”
# blame last edit
git blame
# create file .gitignore to ignore all unnessarry file
node_modules/
log/
*.log
__CACHE
__data/
Git basic
10. Alias
# using git alias
git config --global alias.co checkout à git co
git config --global alias.br branch à git br
git config --global alias.ci commit à git ci
git config --global alias.st status. à git st
# using system. add alias to ~/.zshrc ~/.bash_profile…
alias ga='git add’. à ga
alias gc='git commit -m’ à gc
alias gp='git pull origin’
alias gpu='git push origin’
alias gc='git commit -m'
Git workflow
Git workflow simple
Git tools: server
https://github.com https://bitbucket.com https://gitlab.com
Git tools: client
1. Command line
2. Sourcetree https://www.sourcetreeapp.com/
3. Smartgit. - https://www.syntevo.com/smartgit
4. Github Desktop https://desktop.github.com/
5. Tortoisegit https://tortoisegit.org
6. Gitkaren
7. Gitcola
8. …..
https://github.com/microsoft/vscode/issues/32405
References
1. https://cacm.acm.org/magazines/2016/7/204032-why-google-stores-billions-of-lines-of-
code-in-a-single-repository/fulltext
2. https://git-scm.com/book/en/v2
3. https://svnvsgit.com/
4. https://www.atlassian.com/git/tutorials/comparing-workflows
5. https://nvie.com/posts/a-successful-git-branching-model/

Contenu connexe

Tendances

Git Workshop : Getting Started
Git Workshop : Getting StartedGit Workshop : Getting Started
Git Workshop : Getting Started
Wildan Maulana
 

Tendances (20)

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
 
GIT | Distributed Version Control System
GIT | Distributed Version Control SystemGIT | Distributed Version Control System
GIT | Distributed Version Control System
 
Gitting out of trouble
Gitting out of troubleGitting out of trouble
Gitting out of trouble
 
How to become a Git power user
How to become a Git power userHow to become a Git power user
How to become a Git power user
 
Git - The Incomplete Introduction
Git - The Incomplete IntroductionGit - The Incomplete Introduction
Git - The Incomplete Introduction
 
Git basics
Git basicsGit basics
Git basics
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash Course
 
Introduction git
Introduction gitIntroduction git
Introduction git
 
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
 
Git in pills : git stash
Git in pills : git stashGit in pills : git stash
Git in pills : git stash
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
 
Git 101
Git 101Git 101
Git 101
 
Git introduction workshop for scientists
Git introduction workshop for scientists Git introduction workshop for scientists
Git introduction workshop for scientists
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Git Workshop : Getting Started
Git Workshop : Getting StartedGit Workshop : Getting Started
Git Workshop : Getting Started
 
Web Programming - Git basics
Web Programming - Git basicsWeb Programming - Git basics
Web Programming - Git basics
 
Git in 10 minutes
Git in 10 minutesGit in 10 minutes
Git in 10 minutes
 
Introduction to git and github
Introduction to git and githubIntroduction to git and github
Introduction to git and github
 
Git basics
Git basicsGit basics
Git basics
 

Similaire à Git basic and workflow

Source Code Management with Git
Source Code Management with GitSource Code Management with Git
Source Code Management with Git
Things Lab
 
Git_and_GitHub Integration_with_Guidewire
Git_and_GitHub Integration_with_GuidewireGit_and_GitHub Integration_with_Guidewire
Git_and_GitHub Integration_with_Guidewire
Gandhi Ramu
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践
Terry Wang
 
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践
Terry Wang
 
GIT_training_SoftServeBulgaria2016
GIT_training_SoftServeBulgaria2016GIT_training_SoftServeBulgaria2016
GIT_training_SoftServeBulgaria2016
Peter Denev
 

Similaire à Git basic and workflow (20)

Git introduction
Git introductionGit introduction
Git introduction
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for Artists
 
Git github
Git githubGit github
Git github
 
Learning git
Learning gitLearning git
Learning git
 
Git 101
Git 101Git 101
Git 101
 
Git learn from scratch
Git learn from scratchGit learn from scratch
Git learn from scratch
 
Source Code Management with Git
Source Code Management with GitSource Code Management with Git
Source Code Management with Git
 
Git Series - Part 1
Git Series - Part 1 Git Series - Part 1
Git Series - Part 1
 
GIT from n00b
GIT from n00bGIT from n00b
GIT from n00b
 
Git_and_GitHub Integration_with_Guidewire
Git_and_GitHub Integration_with_GuidewireGit_and_GitHub Integration_with_Guidewire
Git_and_GitHub Integration_with_Guidewire
 
Version control with Git
Version control with GitVersion control with Git
Version control with Git
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践
 
Git
GitGit
Git
 
GIT
GITGIT
GIT
 
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践
 
GIT_training_SoftServeBulgaria2016
GIT_training_SoftServeBulgaria2016GIT_training_SoftServeBulgaria2016
GIT_training_SoftServeBulgaria2016
 
Git training (basic)
Git training (basic)Git training (basic)
Git training (basic)
 
Git presentation
Git presentationGit presentation
Git presentation
 
Github By Nyros Developer
Github By Nyros DeveloperGithub By Nyros Developer
Github By Nyros Developer
 
Git training
Git trainingGit training
Git training
 

Dernier

DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
MayuraD1
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
jaanualu31
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
HenryBriggs2
 

Dernier (20)

DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
 
Learn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic MarksLearn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic Marks
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
Rums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdfRums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdf
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 

Git basic and workflow

  • 1. Content 1. Introduction 2. Git overview 3. Basic git command 4. Git tools 5. Hopee git workflow
  • 2. Introduction ´Distributed Version Control System (DVCS) ´Free opensource (inspired from BitKeeper) ´Original author: Author Linus Torvald ´Initial release 7 April 2005; 13 years ago ´Current mainter Junio Hamano (gitter) Google engineer
  • 3. Overview - CVC vs DVS
  • 4. Overview - Concept 1. Git thinks about its data more like a stream of snapshots. Commit, or save the state it basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot
  • 5. Overview - concept 1. Integrity - Nearly Every Operation Is Local Everything in Git is check-summed before it is stored and is then referred to by that checksum. 2. Git Generally Only Adds Data When you do actions in Git, nearly all of them only add data to the Git database
  • 6. Overviews – Local operations File lifecycle
  • 7. Git basic – SSH https://help.github.com/articles/generating-a-new-ssh-key- and-adding-it-to-the-ssh-agent/#generating-a-new-ssh-key 1. Shell Secure on TCP/IP
  • 8. Git basic 1. Install 2. Clone new project 3. Git config # ubuntu sudo apt-get install git # centos yum install git # Macos brew install git # public repo not require ssh key git clone git@github.com:jwasham/coding-interview-university.git # public repo not require user/password git clone https://github.com/jwasham/coding-interview-university.git # config for local (--local). For global (--global) git config --local user.name 'kan kan’ git config --local user.email ’buikhanh.bk@gmail.com’
  • 9. Git basic 3. Init local repo 4. Push to git server git init git add LICENSE.md README.md # add all file (not recommend when working) git add . # commit to git at local git commit –m ‘init project’ # list remote link to server git remote –v # add 1 link to git repo. Usually using origin git remote add origin git@github.com:1Rhino/coding-interview-university.git # add another git remote link git remote add hopee git@github.com:1Rhino/coding-interview-university.git # push to server git git push origin master (git push hopee master)
  • 10. Git basic 5. create branch 6. Pull data # create new branch develop git branch develop # jump to branch develop git checkout develop # create new branch and jump to it (ussually) git checkout –b develop # fetch data from server to local but not merge git fetch origin develop # merge data from branch develop to master (current branch: master) git merge develop # fetch data from server and merge to current branch git pull origin develop
  • 12. Git basic Git conflict when merge (pull)
  • 13. Git basic 7. Status git status git diff file_name.rb folder_name git difftool file_name.rb folder_name # add file, folder to stage git add file_name.rb folder_name # reset from stage -> modified git reset file_name.rb folder_name # discard change git checkout file_name.rb folder_name
  • 14. Git basic 8. History 9. Ignore # list history commit git log git log --pretty="%h - %s” # blame last edit git blame # create file .gitignore to ignore all unnessarry file node_modules/ log/ *.log __CACHE __data/
  • 15. Git basic 10. Alias # using git alias git config --global alias.co checkout à git co git config --global alias.br branch à git br git config --global alias.ci commit à git ci git config --global alias.st status. à git st # using system. add alias to ~/.zshrc ~/.bash_profile… alias ga='git add’. à ga alias gc='git commit -m’ à gc alias gp='git pull origin’ alias gpu='git push origin’ alias gc='git commit -m'
  • 18. Git tools: server https://github.com https://bitbucket.com https://gitlab.com
  • 19. Git tools: client 1. Command line 2. Sourcetree https://www.sourcetreeapp.com/ 3. Smartgit. - https://www.syntevo.com/smartgit 4. Github Desktop https://desktop.github.com/ 5. Tortoisegit https://tortoisegit.org 6. Gitkaren 7. Gitcola 8. …..
  • 21. References 1. https://cacm.acm.org/magazines/2016/7/204032-why-google-stores-billions-of-lines-of- code-in-a-single-repository/fulltext 2. https://git-scm.com/book/en/v2 3. https://svnvsgit.com/ 4. https://www.atlassian.com/git/tutorials/comparing-workflows 5. https://nvie.com/posts/a-successful-git-branching-model/