GIT

understand the distributed version control

What is Git?

Git is a distributed version control system. Every developer maintains a local copy of the main repository and edits and commits to the local copy.

Git workflow

Distributed version control

Basic commands

Configuration
Clone & Remote
Branch

What is branch?

Pointer to specific commit in your working repo.

Master is the default branch in a git repo.

Rename branch

Log
Revert & Reset

Revert

Reset

  • --soft: keep the history

  • --hard: so embarrased to keep the historycod

Reflog (undo --hard reset)

Merge

Fast-Forward and No-FF

There are 2 types of merge in GIT

Feature
Fast-Forward Merge
No-Fast-Forward Merge

Merge type

Simple, Fast

Complex, require merge commit

Branch history

Linear, no commit

Non-Linear, new merge commits

Merging strategy

used when changes are in SYNC

used when changes have Diverged

Command

git merge <branchname>

git merge --no-ff <branchname>

Rebasing

Cherry pick

  • Use case: when you do not want to merge all the changes from another branch (rebasing), and only want to pick 1 commit from another branch.

Special file in Git

Best practices

  • Keep your commit atomic (1 commit solve 1 issue)

Resources

Last updated