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/

Git basic and workflow

  • 1.
    Content 1. Introduction 2. Gitoverview 3. Basic git command 4. Git tools 5. Hopee git workflow
  • 2.
    Introduction ´Distributed Version ControlSystem (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.
  • 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 – Localoperations 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. Initlocal 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. createbranch 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
  • 11.
  • 12.
    Git basic Git conflictwhen merge (pull)
  • 13.
    Git basic 7. Status gitstatus 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'
  • 16.
  • 17.
  • 18.
    Git tools: server https://github.comhttps://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. …..
  • 20.
  • 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/