21
GIT BRANCHING PHUOC NGUYEN

How to use Git Branch

Embed Size (px)

Citation preview

Page 1: How to use Git Branch

GIT BRANCHINGPHUOC NGUYEN

Page 2: How to use Git Branch

Contents Git Branch Git Checkout, Revert and Reset

Git Workflow Models

Page 3: How to use Git Branch

It's important to understand that branches are just pointers to commits. When you create a branch, all Git needs to do is create a new pointer —it doesn’t change the repository in any other way.

Page 4: How to use Git Branch

Git Checkout Checkout a commit Checkout a file Checkout a branch

Page 5: How to use Git Branch

The lifecycle of the status of your files

Page 6: How to use Git Branch

Git Revert Generate a new commit that undoes all of the changes introduced in <commit>, then apply it to the current branch.

Git Revert does not “revert” back to the previous state of a project

Page 7: How to use Git Branch

Git Reset Git Reset should only be used to undo local changes.

Page 8: How to use Git Branch

CompareCommit File Branch

Git CheckoutMakes the entire working directory match that commit

Unmodify a modified file

Change to another branch

Git RevertUndo a committed snapshot

- -

Git ResetRemove all subsequent commits

Unstage a staged file

Remove all subsequent commits

Page 9: How to use Git Branch

Workflow Models Centralize Workflow Feature Branch Workflow Gitflow Workflow Forking Workflow

Page 10: How to use Git Branch

Gitflow Workflow ModelThe Gitflow Workflow still uses a central repository as the communication hub for all developers.

As in the other workflows, developers work locally and push branches to the central repo. The only difference is the branch structure of the project.

2 Types of Branches: Main branches & Supporting branches

Page 11: How to use Git Branch

The Main Branches Master - the main branch where the source code of HEAD always reflects a production-ready state.

Develop - the main branch where the source code of HEAD always reflects a state with the latest delivered development changes for the next release.

Page 12: How to use Git Branch

The Main Branches

Page 13: How to use Git Branch

Supporting branches Feature branches Release branches Hotfix branches

Page 14: How to use Git Branch

Feature Branches May branch off from: develop

Must merge back into: develop

Branch naming convention: anything except master, develop, release-*, or hotfix-*

Page 15: How to use Git Branch

Feature Branches

Page 16: How to use Git Branch

Release Branches May branch off from: develop

Must merge back into: develop and master

Branch naming convention: release-*

Page 17: How to use Git Branch

Release Branches

Page 18: How to use Git Branch

Hotfix Branches May branch off from: develop

Must merge back into: develop and master

Branch naming convention: hotfix-*

Page 19: How to use Git Branch

Hotfix Branches

Page 20: How to use Git Branch

Workflow Models

Page 21: How to use Git Branch

THANK YOU!