KEMBAR78
Source Control Using Git | PPTX
Version Control Using Git
Christos Mylonas
Senior Software Engineer
Viva Wallet
Agenda
• Version Control
• Git Concepts
• Local & Remote Repositories
• Branching
• Lab
Version Control
What is version control?
• A system that keeps changes to files over time
• Allows collaboration
• View WHAT has been changed
• View WHO has made the changes
• Undoing
• Revert to prior version
What about file copies?
• Multiple directories
• Who made what? hmm?
• Sync
• Compare
What about file copies?
Centralized Version Control
• Everything is stored on a server.
• Checkout -> Edit -> Commit
• Linear development by design
• TFS (<2013), SVN, Perforce, SourceSafe (legendary)
Centralized Version Control
Pros
• Monitoring
• Administration
• Avoid conflicts by design
• Easy to understand
Cons
• Single User Editing
• Single Point of Failure
• Requires Connectivity
• Repository on Server
Centralized Version Control
Distributed Version Control
• No central server.
• All peers have the repository
• Git
• TFS (>2013)
Distributed Version Control
Pros
• Repository mirror
• Multiple workflows
• Non linear development
• Peers
• Edit the same files
• Working alone - offline
Cons
• Difficult to master
Distributed vs Centralized
git
• Linux - Linus Torvalds (~2005)
• Bitkeeper fork
• Goals: Speed, Branches, Distributed
• File based : Everything exist locally
• Git stores snapshots not differences
• No network required (but we can do almost everything)
• SHA-1 hash : integrity + naming things
• command line, full clients, libraries
git popularity
who’s using it
Git Concepts
.git repo
.git repo objects
• a content-addressable file system
• tree
• commit
• blob
• tag
.git repo pointers
Areas
Files
Files are:
Tracked, Untracked or Ignored
.gitignore
Files are in state:
Modified
Staged
Committed
Configuration
• name
• email
• git config --global
Branches
• diverging
• non-linear development
Repositories
• Local (.git directory)
• Remotes (https, ssh)
• On premises
• github.com / bitbucket.org
Local Repositories
Creating
• .git init
• .git directory creation
Cloning
git clone https://github.com/VivaPayments/API.git
Making Changes
• the file lifecycle
• staging
• unstaging
• git add filename
• git add *
Viewing Status
• current status
• history
• git status
• git log
Commiting
• use short descriptive messages
• history
• git commit –m ‘message’
Undoing
• amending commits : git commit -amend
• unstage file : git reset HEAD filename
• unmodifying a modified file: git checkout -- filename
Branching
What is branching
• diverting from the main line
• do some work
• merge back
• have multiple branches at the same time
• switch between branches
Default branches
• master
• develop
Create new branch
• Have clean working state
• Changes files on your working
directory.
• git branch branchname
Switch to branch
• git checkout branchname
Merging (no conflicts)
Merging (with conflicts)
Merging (resolving conflicts)
Merging (resolving conflicts)
Merging (resolving conflicts)
Remote Repositories
Remote Repositories
• Viewing
• Adding new remotes
• Fetch / Pull from remotes
• Pushing to remotes
• Pull requests
Creating a remote
Adding a remote
Diffs on remote
Pull requests on remote
Commits on remote
Remote Branches
• origin/{branch}
• pulling
• pushing
The git workflow
Q&A
Resources
Resources
• https://git-scm.com/
• https://about.gitlab.com/features/
• http://rogerdudler.github.io/git-guide/
• http://danielkummer.github.io/git-flow-cheatsheet/
• http://stackoverflow.com/questions/tagged/git
• https://github.com/github/gitignore
https://gr.linkedin.com/in/chrismylonas
https://www.facebook.com/ChrisMylonas
https://twitter.com/ChrisMylonas
Thank you!
Lab – Check #presentation channel
feel free to ask anything
master develop aliceFeature
bobFeature
origin/master origin/develop
remote repo
`

Source Control Using Git

Editor's Notes