Slide 1

Slide 1 text

Worst Practices for version control Smit Thakkar

Slide 2

Slide 2 text

README.md ● Chief Architect at Corridor Funds ● Contributor at: FossAsia, Gluster and NgUI ● Github: https://github.com/smitthakkar96 ● Email: [email protected]

Slide 3

Slide 3 text

What is version control? Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later. For the examples in this book, you will use software source code as the files being version controlled, though in reality you can do this with nearly any type of file on a computer.

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

ME

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

Version control everything…..

Slide 8

Slide 8 text

● Version control only the source code ● Use .gitignore

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

Commit messages are for losers

Slide 11

Slide 11 text

Things to consider when writing commit messages ● Write the summary line and description of what you have done in the imperative mode, that is as if you were commanding someone. Start the line with "Fix", "Add", "Change" instead of "Fixed", "Added", "Changed". ● Always leave the second line blank. ● Line break the commit message (to make the commit message readable without having to scroll horizontally in gitk).

Slide 12

Slide 12 text

Committing broken code to main branch

Slide 13

Slide 13 text

Committing code with console logs and old commented code

Slide 14

Slide 14 text

Committing unrelated changes

Slide 15

Slide 15 text

Committing directly to master

Slide 16

Slide 16 text

Big monolithic Repository

Slide 17

Slide 17 text

The “fix previous commit” commit 664e6ac (HEAD, master) Fix one line in verification method (4 minutes ago) 3945ef1 Add verification method (5 minutes ago)

Slide 18

Slide 18 text

Solution: git commit --amend

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

What is rebase? ● It is a powerful tool capable of modifying git history ● Enables developers to squash, delete and change order of commits

Slide 21

Slide 21 text

Unorganized workflows

Slide 22

Slide 22 text

Git Workflows ● Centralized Workflow ● Forking Workflow ● Feature branching ● Gitflow workflow

Slide 23

Slide 23 text

Centralized Workflow

Slide 24

Slide 24 text

Centralized Workflow Process ● Initialize the central repository ● Clone the central repository ● Make changes and commit ● Push new commits to central repository ● Manage Conflicts

Slide 25

Slide 25 text

John works on his feature Mary works on her feature John Publishes his feature Mary tries to publish her feature Mary Rebases and Resolves conflicts Mary publishes the feature

Slide 26

Slide 26 text

Forking workflow

Slide 27

Slide 27 text

Steps 1. A developer 'forks' an 'official' server-side repository. This creates their own server-side copy. 2. The new server-side copy is cloned to their local system. 3. A Git remote path for the 'official' repository is added to the local clone. 4. A new local feature branch is created. 5. The developer makes changes on the new branch. 6. New commits are created for the changes. 7. The branch gets pushed to the developer's own server-side copy. 8. The developer opens a pull request from the new branch to the 'official' repository. 9. The pull request gets approved for merge and is merged into the original server-side repository

Slide 28

Slide 28 text

Feature Branching

Slide 29

Slide 29 text

Steps ● Start with the master branch ● Create a new-branch ● Push feature branch to remote ● Update, add, commit, and push changes ● Push feature branch to remote ● Resolve feedback ● Merge your pull request

Slide 30

Slide 30 text

Example

Slide 31

Slide 31 text

Git Flow Workflow

Slide 32

Slide 32 text

The overall flow of Gitflow is: ● A develop branch is created from master ● A release branch is created from develop ● Feature branches are created from develop ● When a feature is complete it is merged into the release branch ● When the release branch is done it is merged into develop and master ● If an issue in master is detected a hotfix branch is created from master ● Once the hotfix is complete it is merged to both develop and master

Slide 33

Slide 33 text

Things to keep in mind when choosing workflow ● Short-lived branches ● Minimize and simplify reverts ● Match a release schedule

Slide 34

Slide 34 text

References ● https://www.atlassian.com/git/tutorials ● https://images.google.com

Slide 35

Slide 35 text

Questions?