Skip to content
Search

Git

lastmod 2026-04-28created 2014-01-05185 edits

Git is a distributed version control system for managing the source code of programs and the like. It is characterized by its focus on fast performance. It was originally developed by Linus Torvalds for Linux kernel development, but is now widely used. Every Git working folder is a full-fledged repository containing the complete history and the information needed to track each record. It does not depend on network access or a central server. Junio Hamano currently oversees the software's maintenance. Git is free software distributed under the GNU General Public License v2.

What you should know about git beforehand is as follows.

  • A git repository is divided into 3 stages: the repository where committed sources are kept, the working tree where the current project files are, and the staging area, a buffer between the repository and the working tree where the items to be committed are stored.
  • git does not track empty directories.
  • Files that should not be under configuration management are added to the .gitignore file.
  • HEAD means the latest commit of the current branch.
  • The default remote repository is called origin.

Workspaces

Stash
Workspace
Index
Local Repository
Upstream Repository

Categories

git-flow branch example

References on how to use Git.

Administration

Notes on Git maintenance and recovery.

Git Hook

Security

  • git-secrets - Prevents sensitive information leaks, made by AWS
  • gitleaks - Find secrets with Gitleaks

Git Server

ETC

  • Git:DefaultTemplate: Git project default template.
  • bit - A Git client with autocompletion support
  • git-split-diffs - GitHub style split diffs in your terminal
  • ToolGit - Git productivity toolkit
  • Gitpod - An open-source remote development platform.
  • gitu - TUI Git Client
  • Tig - text-mode interface for Git
  • GitDiagram - Visualizes a GitHub Repo as an interactive diagram (useful for analyzing projects)
  • Gitingest - A tool that converts a Git repository into AI-friendly text
  • Repomix - A tool that converts your codebase into an AI-friendly format
  • git-who - Who wrote this code?!
  • AI Git Narrator - An AI-based tool that automatically generates Git commit messages and PR descriptions
  • Backlog.md
  • lazygit
  • git-quick-stats - Simply and efficiently view various statistics of a Git repository
  • git-annex - A large file management tool for Git users
  • git-rewrite-commits - A tool that automatically rewrites Git commit messages with AI
  • gitui - Blazing 💥 fast terminal-ui for git written in rust 🦀
  • git-memento - If AI writes the code, should the session be part of the commit too?

Flows

Install

On Windows, use winget:

winget install --id Git.Git -e --source winget

Linux family

sudo apt install git

Pushing directly over Git over SSH (from local to server)

How to turn a server you can SSH into into a Git repository and push to it directly over SSH from local:

# 서버에 bare 리포지토리 생성
# Server: Create a bare repository
ssh user@server "mkdir -p /path/to/repo.git && cd /path/to/repo.git && git init --bare"

# 로컬에서 리모트 추가 및 푸시
# Local: Add remote and push
cd /local/project
git remote add production ssh://user@server/path/to/repo.git
git push production main

# 서버에서 작업 디렉토리로 체크아웃
# Server: Checkout to working directory
ssh user@server "cd /path/to/working && git clone /path/to/repo.git ."

Replacing the default Upstream (Origin)

If the Remote looks like this:

$ git remote -v
origin  https://github.com/ops/ops (fetch)
origin  https://github.com/ops/ops (push)
aaa     https://github.com/aaa/bbb (fetch)
aaa     https://github.com/aaa/bbb (push)

It takes three commands:

## 현재 Origin 의 이름 변경 (참고로 이렇게 되면 현재 Branch 의 Upstream 이 변경된 이름으로 가리키게 되므로 나중에 Origin 으로 바꿔야 한다)
git remote rename origin temp

## 지정하고 싶음 Remote 를 Origin 으로 변경
git remote rename aaa origin

## 현재 로컬 브랜치의 Upstream 을 Origin 으로 변경
git branch --set-upstream-to=origin/main

Tools

  • If you use GitHub, take a look at the GitGuardian service
  • If you use GitLab, consider upgrading to Gold/Ultimate
  • To prevent leaks in advance, use Talisman (Pre-Commit Hook)
  • To check afterward whether something leaked, consider adopting GitLeaks
  • Flux for GitOps

How to apply user information temporarily

git -c user.name=사용자명 -c user.email=이메일주소 ...

Change Working Directory

When using a command like git pull, you can change the working path like make -C /dir without changing the working directory with cd:

git --work-tree=/X/Y --git-dir=/X/Y/.git pull origin branch

Pull Request vs Merge Request

Merge or pull requests are created in a Git management application. <- (git itself has no such feature. It is a name coined by tools such as github/gitlab.)

They ask an assigned person to merge two branches.

  • Tools such as GitHub and Bitbucket choose the name "pull request" because the first manual action is to pull the feature branch.
  • Tools such as GitLab and others choose the name "merge request" because the final action is to merge the feature branch.

Original text:

Merge or pull requests are created in a Git management application. They ask an assigned person to merge two branches. Tools such as GitHub and Bitbucket choose the name “pull request”, because the first manual action is to pull the feature branch. Tools such as GitLab and others choose the name “merge request”, because the final action is to merge the feature branch. This article refers to them as merge requests.

So the two terms mean the same thing.

How to turn off automatic updates on Windows

Disable "Git for Windows Updater" in "Task Scheduler" (it's different from Services, Services is).

It can be launched with the mmc command.

Ways to undo mistakes

  • Ways to undo mistakes (restore, reset, revert)
  • restore - A command for recovery. Typically, it can move files that were put in the Staging Area with the git add command back to the Working Directory. Use git restore --staged ... for this.
    • Also used to restore a file that was committed earlier (e.g. git restore --source=8d9bb2c cloud-torrent)
  • reset - Lets you go back to a specific commit. However, true to the name reset, all subsequent commits are reset and disappear from the history.
  • revert - Cancels only a specific commit. The history isn't wiped out; instead, a new commit is made that undoes that commit's changes.

Git commands to run before reading code

When facing a new codebase, analyze the Git history to understand the project's structure and risk areas and set an efficient direction for exploration

  • Find the files changed most often in the past year and cross-analyze change frequency with bug concentration to identify high-risk code
  • Check bus factor, maintenance gaps, and possible knowledge loss through contributor distribution and activity trends
  • Track changes in the team's development pace and momentum with monthly commit counts, and assess deployment stability with Revert·Hotfix frequency
  • These five commands can serve as practical tools for quickly diagnosing project health before opening a single line of code

What changes most often

git log --format=format: --name-only --since="1 year ago" | sort | uniq -c | sort -nr | head -20
  • Shows the top 20 most-modified files in the past year
  • The top files are often ones the team is "afraid to touch"; when high change frequency (churn) combines with ownership avoidance, they are the biggest burden on the codebase
  • According to a Microsoft Research (2005) study, change-frequency-based metrics predict defects better than complexity metrics
  • Cross-analyze the top 5 files with the bug concentration command to identify files with many changes and many bugs as the biggest risk

Who built this code

git shortlog -sn --no-merges
  • Ranks contributors by commit count
  • If one person accounts for 60% or more, there is a bus factor risk
  • If the top contributor hasn't been active in the last 6 months, there may be a maintenance gap
  • If only 3 of 30 contributors have been active in the past year, knowledge loss has occurred due to developer turnover
  • However, teams using a squash-merge strategy may have author information skewed toward the merger, so check the merge strategy

Where bugs concentrate

git log -i -E --grep="fix|bug|broken" --name-only --format='' | sort | uniq -c | sort -nr | head -20
  • Extracts the top 20 bug-prone files based on commits containing bug-related keywords
  • Compare this list with the change frequency list to identify files that are changed often and break often as high-risk code
  • Result accuracy depends on commit message quality, but it is useful enough as a rough bug density map

Is the project accelerating or stagnating

git log --format='%ad' --date=format:'%Y-%m' | sort | uniq -c
  • Visually grasp activity trends through monthly commit counts
  • A steady rhythm means a healthy project
  • If commits drop by half in a single month, key people may have left
  • A sustained decline over 6–12 months suggests declining team momentum; periodic spikes followed by stagnation suggest a batch release pattern
  • In one real case, a CTO realized from the commit velocity chart that "that was when the senior engineer left"
  • This data is meaningful as team data, not code data

How often the team is firefighting

git log --oneline --since="1 year ago" | grep -iE 'revert|hotfix|emergency|rollback'
  • Measures Revert·Hotfix frequency
  • A few a year is normal, but if it happens every two weeks, it signals distrust of the deployment process
  • This is a symptom of deeper problems such as flaky tests, no staging, or complex rollback procedures
  • If the result is 0, either the team is stable or the commit messages are inaccurate
  • Crisis patterns show up clearly, and their presence alone lets you judge reliability

Troubleshooting

Notes on problems that can occur while using Git.

See also

Favorite site

Developers

Migration

Tip

References


  1. Git_simple_guide_ko.pdf ↩

  2. Ndpsoftware.com-git-cheatsheet.zip ↩

  3. Open_source_-VCS-_Git_command_list.pdf ↩

  4. Dogfeet-git_secrets.pdf ↩

  5. Backlogtool_com_git-guide_kr.zip ↩

  6. Fixing_broken_commit_messages.pdf ↩

  7. Rogerdudler-git-guide.zip ↩

  8. Introduction_tortoisegit.zip ↩

  9. Visual-git-guide.zip ↩

  10. Using_git_with_dropbox.pdf ↩

  11. Rogerdudler.github.com-git_cheat_sheet.pdf ↩

  12. Salesforce_git_developer_cheatsheet.pdf ↩

  13. Namhyung.springnote.com-git_users_guide.pdf ↩

  14. Git-tutorial_vogella.com_kor.pdf ↩

  15. How_to_Write_a_Git_Commit_Message_-_item4_Dev_Story.pdf ↩

  16. Appkr-git-comparing_workflows.pdf ↩

author Zer0 sitemap