Git and GitFlow branching model
-
Upload
pavlo-hodysh -
Category
Software
-
view
67 -
download
1
Transcript of Git and GitFlow branching model
Working with source codeWhat we do:- Copy & paste files &
folders- Carry code on
external drives- Backup using manual
copies
Problems:- Forget to make a
copy- Hard to manage
copies- Hard to share
versions between collaborators
- Hard to share access- No descriptive history
Working with source codeWhat I want:- Automatically backup- Keep history of
changes- Easily share code- Easily share access- Collaborate in teams
Solution:- Use a VCS already!
What is version control?A component of software configuration management, version control (revision control, source control), is the management of changes to documents, computer programs, large web sites, and other collections of information (from Wikipedia)
What problems does it solve?Pros.- Work in teams- Automatic backup - Revision history- Automatic builds on
CI
Cons.- You need to learn it- You need to install it
… yeah, like it’s hard
Version Control SystemsGeneration 0 - The stone age (Ctrl + C -> Ctrl + V)Generation 1 - Local (RCS, SCCS)Generation 2 - Centralized (CVS, Subversion, Team Foundation)Generation 3 - Distributed (Git, Mercurial)
Basic conceptsRepository:- Place where you store your source code- Contains every revision of your code- Shares access to source code for your team- Serves as a backup for yahoo source code
REPOSITORY
Basic concepts
Working copy:- Snapshot of your last commit- Place where changes are added- Local, visible only by you- Contains metadata about state of things
- Files added- Files modified- Files renamed- Files deleted
WORKING COPY
Basic concepts
Commit:- Moves working copy to a repository- Has a description message- Has a revision number
REPOSITORY
WORKING COPY
COMMIT
Basic concepts
Update:- Updates the working copy from a repository- Merges changes with working copy
REPOSITORY
WORKING COPY
UPDATE
Centralized Version Control- Remote repository- Multiple clients, one server
REPOSITORY
WORKING COPY
WORKING COPY
WORKING COPY
Distributed Version Control- Multiple clients with multiple local repositories- One centralized server
REPOSITORY
WORKING COPY
WORKING COPY
WORKING COPY
Basic concepts
Pull:- Updates the local repository from a remote
repository- Merges changes with working copy on local
repository
LOCAL REMOTE
PULL
Basic concepts
Push:- Moves changes from local repository to remote- Moves all history from last push
LOCAL REMOTE
PUSH
Getting started with GitStandard installations- http://git-scm.com/downloads
Available for all the platform
Git Graphical Applications- http://git-scm.com/downloads/guis- https://www.sourcetreeapp.com/- https://www.gitkraken.com/
GitFlow branching modelKey Benefits- Stable versions ready for production via master branch
- Staging area via develop branch
- Collaboration via feature branches
- Releases area via release branches
- Support for emergency fixes via hotfix branch
How it works?- We start with master branch
- Create develop branch from master
- Create feature branches from develop
How it works?- We develop our features in
separate feature branches
- When the feature is finished we merge it back into develop
How it works?- When it is time to make a
release, create a release branch from develop
- Code in the release branch is deployed, tested, and any bugs are fixed directly in the release branch
- When finished, the release branch is merged into master and into develop, so that all bug fixes are not lost
How it works?- In case of bugs on production
we create hotfix branch from master
- When finished, merge back into both master and develop to make sure that the hotfix isn’t accidentally lost
Merge vs. Rebase- Merging brings two lines of
development together while preserving the ancestry of each commit history.
- Rebasing unifies the lines of development by rewriting changes from the source branch so that they appear as children of the destination branch
Golden rule of rebasing
NEVER EVERrebase a branch that you pushed,
or that you pulled from another person
Pull requests- Create a pull requests
from feature branch
- Let the peer review and comment the code
- When the pull request is approved feature branch is merged
Useful linksGitFlow by Vincent Driessenhttp://nvie.com/posts/a-successful-git-branching-model/
GitFlow Cheatsheethttp://danielkummer.github.io/git-flow-cheatsheet/
Git workflow by Atlassianhttps://www.atlassian.com/git/tutorials/comparing-workflows/feature-branch-workflow
GitFlow step-by-stephttps://datasift.github.io/gitflow/IntroducingGitFlow.html