Basics
What does the industry say about Git?
“Git is amazingly fast, it’s very efficient with large projects, and it has an incredible branching system for non-linear development” - Scott Chacon and Ben Straub; authors of Pro Git
Why is Git so popular?
What is Git?
Git is a free and open source distributed version control system(VCS) designed to handle everything from small to large projects with speed and efficiency. GitLab is a Git-based fully integrated platform for software development.
Characteristics of Git
- Distributed- Does not require a constant connection to a central server.
- Adaptive- Git’s branching model can adapt to fit the workflow of almost any team.
- Fast & Reliable- Git branches are sparse, allowing for change-only tracking.
- Flexible- Git can be command line or GUI driven, allowing everyone to contribute easily.
Traditional Developer Process
DEVELOPERS
- Developers have access to the entire code base
- All files are stored
- Operations are performed directly on the repository
CODE CHANGES
Since changes are made to a central repository, other developers are not aware of code changes a developer makes until they merge it to the central repository.
CENTRAL REPOSITORY
- Developers work using local copy of the repo
- Then check in their changes and resolve any possible conflicts
Git Term Definitions
There are several terms that are used when learning how Git. Click on each card to learn how the term is defined.
- Branch - A branch is an independent line of development.
- Tag - Mark a specific point in time on a branch.
- Checkout - Get a specific branch to start making your changes.
- Commit - Add changes you’ve made to the repository.
- Push - Send changes to a remote directory.
- Workspace - Directory where you store the repository on your computer.
Why is Git so popular?
Central Repository vs. Remote Repository
Terms used when working with Git locally
- Untracked Files – New files that git has not been told to track previously
- Working Area – Files that has been modified but not committed
- Staging Area – Modified/Added files that are marked to go into the next commit
- Local Repo – Local copy of upstream repo
- Remote/Upstream Repo – Hosted repository on a shared server (Gitlab)
Centralized vs. Distributed
Let’s take a look at the various advantages of using a distributed VCS over a centralized VCS.
DATA LOSS
- It is safer for data loss:
- Each developer has a clone from the repo
- Even a CI server has a trustable source of backup
SPEED
- It is faster:
- Most of the operations doesn’t require network
- It’s less bureaucratic- you can create branches, commits, and merges without accessing the remote repository
COLLABORATION
- More collaborative
- You can have several remote repositories
- Allows you collaborate with different developers without changing the official repository (using forks for example)
Basic Git Workflow with GitLab
GitLab is based on Git and provides your team with a central repository. You use git locally on your own system to create and update code, share your changes with your team, and see your team’s changes by using git commands to push, fetch, and merge work.
GitLab Cheat Sheet
GitLab maintains a cheat sheet of git commands for easy access. This cheat sheet can be accessed using the below link: https://about.gitlab.com/images/press/git-cheat-sheet.pdf
Exercise
LAB 02