BlogBlog

  • Home
  • Blog
  • Introduction to Git | How Git Works

Introduction to Git | How Git Works General

Jul 15, 2021 Tai

Introduction to Git | How Git Works

What is Git?

Widely known, as defined in Wikipedia, Git is a distributed version-control system for tracking changes in source code during software development. It was originally designed and developed by Linus Torvalds (creator of the Linux kernel) and is the most popular version control system to date.

It is equipped for enabling coordination work among programmers and data scientists, which can be used to track changes in any set of files. Its goals include speed, data integrity, and support for distributed and non-linear workflows.

Must-learn Git functions to get started

  • Workflow
  • Repositories
  • Staging and Committing changes
  • Undo
  • Working with branches
  • Sharing for collaboration

How to set up Git repository

Please follow the links below to download and setup Git properly.
After installing Git, please run these commands in order to set Git config.

Windows
https://gitforwindows.org/

Mac
http://git-scm.com/download/mac

  1. git config –global user.email your.email.add@shiftasia.com
  2. git config –global user.name “Your names here and inside quotes”
  3. git config –global core.autocrlf

Common Git Terminologies

Repository

Place where git stores information to manage project or a set of files as they change over time

Staging area

Place to keep track changes between repository and working directory

Working directory

Place where you work with files & folders

HEAD

HEAD is a reference to the last commit in the currently check-out branch (local branch). HEAD can be the last commit from branch or can be switch to any commit

* Commit hash * Commit Id * Revision number

SHA-1 checksum to identify a commit

Basic commands in git

Checkout a repository

git clone </path/to/repository>

Add a file

git add

Commit changes

Git commit –m “Commit message”

Push changes

Git push

Create then switch to a branch

Git checkout –b

Switch branch

Git checkout

Update and merge changes

Git pull

Update changes

Git fetch

Merge changes

Git merge /

Revert local changes

Git checkout —

Revert all local changes

Git checkout — .

Create new repository

Git init

Add a remote repository

Git remote add </path/to/repository>

Reset whole branch

Git fetch origin

Tagging

Git tag

List commit logs

Git log

Use more and Get comfortable

The shortest way to master Git is, to use it in projects. We recommend simulating a smaller group project, by creating files, naming it after the project, control branches and committing changes. Best practice includes adding an easy-to-understand commit messages. In a separate article, we will address naming convention for Git messages we use in projects at SHIFT ASIA – One of the leading software quality assurance companies.

For any inquiries, please drop us a message through contact form.

ContactContact

Stay in touch with Us

What our Clients are saying

  • We asked Shift Asia for a skillful Ruby resource to work with our team in a big and long-term project in Fintech. And we're happy with provided resource on technical skill, performance, communication, and attitude. Beside that, the customer service is also a good point that should be mentioned.

    FPT Software

  • Quick turnaround, SHIFT ASIA supplied us with the resources and solutions needed to develop a feature for a file management functionality. Also, great partnership as they accommodated our requirements on the testing as well to make sure we have zero defect before launching it.

    Jienie Lab ASIA

  • Their comprehensive test cases and efficient system updates impressed us the most. Security concerns were solved, system update and quality assurance service improved the platform and its performance.

    XENON HOLDINGS