본문 바로가기
DevTools/Git

[Git] Getting Started

by llHoYall 2020. 9. 23.

git

Git is a distributed version control system.

It is designed to handle everything from small to very large projects with speed and efficiency.

Installation

- Mac

Mac has Git already.

$ brew install git git-lfs

- Linux (Ubuntu)

$ sudo apt install git git-lfs

- Windows

$ choco install -y git git-lfs

Git Basics

Repository

The git repository is a repository managed by the Git.

This is a simple usage of Git.

There are one shared server and three local systems.

Synchronize the works through a shared server.

Branch

Git can make branches freely.

Create branches for feature development,  bug fix, or experimental purposes, and you can be freely developed on those branches.

Those branches can be combined by the master branch when desired, or deleted, or left.

The Three State

Git manages the files in three states: committed, staged, and modified.

  • Committed : The state in which the file is safely stored in the local database.
  • Staged : The state marked to commit the modified file.
  • Modified : The modified file has not yet been committed to the local database.

.git folder refers to where Git stores metadata and object database of the project, and is the core of Git.

Working directory is a checked out content of a particular version.

The .git folder is located on the disk where you are currently working, and the file is taken from the compressed database in the .git folder to create the working directory.

Staging area is located in the .git folder and stores information about the files to be committed.

 

The files in the .git folder are committed state.

If the file has been modified and added to the staging area, it is staged state.

It is modified state if it has been modified after checkout but has not been added to the staging area yet.

 

What Git does is basically:

  • Modify the files in the working directory.
  • Stage the files in the staging area and create a snapshot to commit.
  • Commit the files in the staging area and save them as a permanent snapshot in the .git folder.

 

HEAD is the pointer that currently refers to the branch and refers to the last commit among the commits in the branch.

INDEX is the next commit. That is to say, the staging area. Technically, it is not a tree structure.

Working directory refers to where the file currently works by the user is located.

The Lifecycle of the Status of the Files

Fundamental Usages

Protocol

The protocol used for data transfer between the local repository and the remote repository can be divided into four types.

Local

This is the simplest way to use the local file system.

The downside is that external access is slow and difficult.

 

These are some usage examples.

$ git clone /opt/git/project.git
$ git clone file:///opt/git/project.git

Git

Use daemon included in Git using 9418 port.

No authentication and security; fastest transfer rate.

 

These are some usage examples.

$ git clone git://example.com/project.git
$ git clone git@example.com/project.git

SSH

It is efficient because it is easy to set up, safe to security, and compressing data on transmission.

Because anonymous access is not possible, it has difficulties to use in the open source project.

 

These are some usage examples.

$ git clone ssh://user@server/project.git
$ git clone user@server:project.git

HTTPS

It allows authenticating using a user name and password.

Both anonymous and authenticated use are possible.

 

This is a usage example.

$ git clone https://example.com/project.git

'DevTools > Git' 카테고리의 다른 글

[Git] Tip: Revert Merged Commit  (0) 2021.03.05
[Git] Tip: Change committer and author from already committed commit  (0) 2021.02.15
[Git] Restore Command  (0) 2020.10.23
[Git] Switch Command  (0) 2020.10.23
[Git] Config Command  (0) 2020.09.23

댓글