Git Commit

7756 ๋‹จ์–ด gitgit

Commit์ด๋ž€ ์–ด๋– ํ•œ ํฌ์ธํŠธ์—์„œ ํ˜•์ƒ์„ ๊ธฐ๋กํ•˜๋Š” ๊ฒƒ

๊ทธ๋ž˜์„œ Commit์„ ์‹คํ–‰ํ•˜๊ธฐ ์ „์—, ์–ด๋– ํ•œ ์ฝ”๋“œ, ์–ด๋– ํ•œ ํŒŒ์ผ๋“ค์„ ํ˜•์ƒ์œผ๋กœ ๊ธฐ๋กํ•  ์ง€ ์„ ๋ณ„ํ•˜๋Š” ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•ด์•ผ ํ•œ๋‹ค.

SVN์˜ Commit ๊ณผ๋Š” ์ „ํ˜€ ๋‹ค๋ฅธ ๊ธฐ๋Šฅ์ด๋‹ค.
SVN์˜ Revision ์ด๋ผ๊ณ  ์ƒ๊ฐํ•˜๋ฉด ๋œ๋‹ค.

์„ ๋ณ„ ์ž‘์—…

Tracked Changes

  • ์–ด๋– ํ•œ ํŒŒ์ผ(๋””๋ ‰ํ„ฐ๋ฆฌ)๊ฐ€ ํ˜•์ƒ์œผ๋กœ ๋“ฑ๋ก๋˜๋ฉด, ๊ทธ ์ดํ›„๋ถ€ํ„ฐ Git์—์„œ๋Š” ํ•ด๋‹น ํŒŒ์ผ(๋””๋ ‰ํ„ฐ๋ฆฌ)์„ Trackingํ•˜๊ธฐ ์‹œ์ž‘ํ•œ๋‹ค.
  • ์ด๋ ‡๊ฒŒ Tracking ํ•˜๊ณ  ์žˆ๋Š” ํŒŒ์ผ(๋””๋ ‰ํ„ฐ๋ฆฌ) ์ค‘์—์„œ ์ˆ˜์ •์‚ฌํ•ญ์ด ๋ฐœ์ƒํ•œ ๋ชฉ๋ก์„ ์˜๋ฏธํ•œ๋‹ค.
  • ๋ณดํ†ต์€ ํŒŒ์ผ(๋””๋ ‰ํ„ฐ๋ฆฌ) ์ˆ˜์ •/์ด๋™/์‚ญ์ œ๋œ ๊ฒฝ์šฐ์— ํ•ด๋‹น

Untracked List

  • ํ˜•์ƒ ๋“ฑ๋ก์ด ๋˜์ง€ ์•Š์€ ํŒŒ์ผ(๋””๋ ‰ํ„ฐ๋ฆฌ) ๋ชฉ๋ก
  • ๋ณดํ†ต์€ ํŒŒ์ผ(๋””๋ ‰ํ„ฐ๋ฆฌ) ์ถ”๊ฐ€๋œ ๊ฒฝ์šฐ์— ํ•ด๋‹น

Stage

  • Commit ์ˆ˜ํ–‰ ์‹œ ํ˜•์ƒ์œผ๋กœ ๊ธฐ๋กํ•  ํŒŒ์ผ์ด๋‚˜ ์ฝ”๋“œ ๋“ฑ์˜ ๋ฆฌ์ŠคํŠธ
  • Tracked changes, untracked list์—์„œ ํ˜•์ƒ์œผ๋กœ ๊ธฐ๋กํ•  ๊ฒƒ๋“ค์„ ์„ ๋ณ„ํ•˜์—ฌ Stage๋กœ ์ด๋™์‹œํ‚ด

๊ด€๋ จ ๋ช…๋ น์–ด

  • add
  • del
  • commit
  • rm
  • status
  • tag

add

### Add to stage ###
# Tracked changes์™€ Untracked list์˜ ํŠน์ • ํŒŒ์ผ(๋””๋ ‰ํ„ฐ๋ฆฌ)๋ฅผ Stage์— ์ถ”๊ฐ€
$ git add [files or dirs]

# Tracked changes์™€ Untracked list์˜ ๋ชจ๋“  ํŒŒ์ผ(๋””๋ ‰ํ„ฐ๋ฆฌ)๋ฅผ Stage์— ์ถ”๊ฐ€
$ git add -A

del

### Delete from stage ###
# Stage์— ์žˆ๋Š” ํŠน์ • ํŒŒ์ผ(๋””๋ ‰ํ„ฐ๋ฆฌ)๋ฅผ Stage์—์„œ ์ œ์™ธ
$ git del [files or dirs]

# Stage์— ์žˆ๋Š” ๋ชจ๋“  ํŒŒ์ผ(๋””๋ ‰ํ„ฐ๋ฆฌ)๋ฅผ Stage์—์„œ ์ œ์™ธ
$ git del -A

commmit

### Restore stage ###
$ git commit

์ปค๋งจ๋“œ๋ฅผ ์‹คํ–‰ํ•˜๋ฉด, ์—๋””ํ„ฐ๊ฐ€ ์‹คํ–‰๋˜๋ฉด์„œ Commit ๋ฉ”์„ธ์ง€๋ฅผ ์ž‘์„ฑํ•˜๋Š” ํ™”๋ฉด์œผ๋กœ ์ž๋™ ์ „ํ™˜๋ฉ๋‹ˆ๋‹ค.

์ด ๋•Œ ์‹คํ–‰๋˜๋Š” ์—๋””ํ„ฐ๋Š” Repo config์˜ core.editor์— ์„ค์ •๋œ ์—๋””ํ„ฐ์ž„

๋ฉ”์‹œ์ง€๋ฅผ ๋ชจ๋‘ ์ž‘์„ฑํ•œ ํ›„, ์—๋””ํ„ฐ๋ฅผ ์ข…๋ฃŒํ•˜๋ฉด Commit ์™„๋ฃŒ

Commit ๋ฉ”์„ธ์ง€๋ฅผ ์ž‘์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ๋’ค์—์„œ ๋‹ค๋ฃฐ ์˜ˆ์ •.

Commit์ด ์™„๋ฃŒ๋˜๋ฉด History๊ฐ€ ๊ธฐ๋ก๋˜๋Š”๋ฐ, $ git log ์ปค๋งจ๋“œ๋กœ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

๋˜ํ•œ ๊ฐ Commit๋งˆ๋‹ค Commit number๊ฐ€ ๋ถ€์—ฌ๋˜๋Š”๋ฐ ์ด ๋˜ํ•œ log ์ปค๋งจ๋“œ๋กœ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค(๋นจ๊ฐ„์ƒ‰ ํ™”์‚ดํ‘œ).

rm

### Remove from tracked list
# ํŠน์ • ํŒŒ์ผ(๋””๋ ‰ํ„ฐ๋ฆฌ)๋ฅผ Tracked list์—์„œ ์ œ์™ธ์‹œํ‚ด๊ณผ ๋™์‹œ์— ์‚ญ์ œ
$ git rm [files or dirs]

# ํŠน์ • ํŒŒ์ผ(๋””๋ ‰ํ„ฐ๋ฆฌ)๋ฅผ Tracked list์—์„œ ์ œ์™ธ๋งŒ ์‹œํ‚ค๊ณ  ์‚ญ์ œ๋Š” ํ•˜์ง€ ์•Š์Œ
$ git rm --cached [files or dirs]

status

### Check unstaged list ###
$ git status
# Staged files
Changes to be committed:
			deleted:    file_a

# Tracked changes
Changes not staged for commit:
			modified:   file_b

# Untracked list
Untracked files:
			file_c
			file_d

tag

# Register tag
$ git tag <tag-name>

# Example
$ git tag v0.0.0

# Check tags
$ git tag

ํŠน์ • Commit ํฌ์ธํŠธ์—์„œ Tag๋ฅผ ๋‚จ๊ธธ ์ˆ˜ ์žˆ๋‹ค.

๋ณดํ†ต์€ ๋ฒ„์ „๋ช…์„ ๊ธฐ๋กํ•  ๋•Œ ์‚ฌ์šฉ๋œ๋‹ค.

Commit Rule

$ git commit ์„ ์‹คํ–‰ํ•˜๋ฉด, Commit ๋ฉ”์„ธ์ง€๋ฅผ ์ž‘์„ฑํ•ด์•ผ ํ•œ๋‹ค.

๊ฐ์ž ํ™˜๊ฒฝ์— ๋งž๊ฒŒ ์ž‘์„ฑํ•˜๋ฉด ๋˜์ง€๋งŒ, ์ผ๋‹จ ๋จผ์ € Global conventional commit rule์„ ์†Œ๊ฐœํ•˜๊ณ ์ž ํ•œ๋‹ค.

Global conventional commit rule

๊ธฐ๋ณธ ํ‹€์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

type : title

body(์ƒ๋žต ๊ฐ€๋Šฅ)

footer(์ƒ๋žต ๊ฐ€๋Šฅ)
  • type

    Commit์˜ ํƒ€์ž…์„ ์ •์˜ํ•œ๋‹ค. ์ด ์ปค๋ฐ‹๋ฃฐ์—์„œ ์ •์˜ํ•œ ๋ชฉ๋ก์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

    • feat : ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ์— ๋Œ€ํ•œ ์ปค๋ฐ‹
    • fix : ๋ฒ„๊ทธ ์ˆ˜์ •์— ๋Œ€ํ•œ ์ปค๋ฐ‹
    • build : ๋นŒ๋“œ ๊ด€๋ จ ํŒŒ์ผ ์ˆ˜์ •์— ๋Œ€ํ•œ ์ปค๋ฐ‹
    • chore : ๊ทธ ์™ธ ์ž์ž˜ํ•œ ์ˆ˜์ •์— ๋Œ€ํ•œ ์ปค๋ฐ‹
    • ci : CI ๊ด€๋ จ ์„ค์ • ์ˆ˜์ •์— ๋Œ€ํ•œ ์ปค๋ฐ‹
    • docs : ๋ฌธ์„œ ์ˆ˜์ •์— ๋Œ€ํ•œ ์ปค๋ฐ‹
    • style : ์ฝ”๋“œ ์Šคํƒ€์ผ ๋˜๋Š” ํฌ๋งท ๋“ฑ์— ๋Œ€ํ•œ ์ปค๋ฐ‹
    • refactor : ์ฝ”๋“œ ๋ฆฌํŒฉํ† ๋ง์— ๋Œ€ํ•œ ์ปค๋ฐ‹
    • test : ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ˆ˜์ •์— ๋Œ€ํ•œ ์ปค๋ฐ‹
  • title

    Commit์˜ ์ œ๋ชฉ์„ ์ •์˜ํ•œ๋‹ค.

  • body

    ํ•„์š” ์‹œ ๋ณธ๋ฌธ ๋ฐ ์„ธ๋ถ€ ๋‚ด์šฉ์„ ๋ช…์‹œํ•œ๋‹ค.

    ๋˜ํ•œ ์ƒ๋žต ๊ฐ€๋Šฅํ•˜๋‹ค.

  • footer

    ์‚ฌ์กฑ์„ ๋‚จ๊ธด๋‹ค.

    ์ƒ๋žต๋„ ๊ฐ€๋Šฅํ•˜๋‹ค.

    ํ•˜์ง€๋งŒ ๋ณดํ†ต ํ•ด๋‹น Commit๊ณผ ์—ฐ๊ด€๋œ Issue tracker ID๋ฅผ ๋ช…์‹œํ•œ๋‹ค.

    • close #

      ์ผ๊ฐ์ด ์™„๋ฃŒ๋˜์—ˆ์Œ์„ ๋‚˜ํƒ€๋ƒ„

    • resolved #

      ์ด์Šˆ๊ฐ€ ํ•ด๊ฒฐ๋˜์—ˆ์Œ์„ ๋‚˜ํƒ€๋ƒ„

    • refs #

      ํ˜„์žฌ ์ง„ํ–‰ ์ค‘์ธ ์ผ๊ฐ(or ์ด์Šˆ)๋ฅผ ๋‚˜ํƒ€๋ƒ„

    • related to # # #...

      ๊ด€๋ จ ์ผ๊ฐ๋“ค์„ ๋‚˜ํƒ€๋ƒ„(๋ณต์ˆ˜ ์ง€์ • ๊ฐ€๋Šฅ)

์ด Rule์—์„œ ์ •์˜ํ•˜๋Š” 7๊ฐ€์ง€ ๊ทœ์น™์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

  • title ๊ณผ body ๋Š” ๋นˆ ํ–‰์œผ๋กœ ๊ตฌ๋ถ„ํ•œ๋‹ค.
  • title ์€ 50์ž ์ด๋‚ด๋กœ ์ œํ•œํ•œ๋‹ค.
  • title ์ฒซ ๊ธ€์ž๋Š” ๋Œ€๋ฌธ์ž๋กœ ์ž‘์„ฑํ•œ๋‹ค.
  • title ๋์— ๋งˆ์นจํ‘œ๋ฅผ ๋„ฃ์ง€ ์•Š๋Š”๋‹ค.
  • title ์€ ๋ช…๋ น๋ฌธ์œผ๋กœ ์‚ฌ์šฉํ•˜๋ฉฐ ๊ณผ๊ฑฐํ˜•์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š”๋‹ค.
  • body ์˜ ๊ฐ ํ–‰์€ 72๊ธ€์ž ๋‚ด๋กœ ์ œํ•œํ•œ๋‹ค.
  • ์–ด๋–ป๊ฒŒ ๋ณด๋‹ค๋Š” ๋ฌด์—‡๊ณผ ์™œ๋ฅผ ์„ค๋ช…ํ•œ๋‹ค.

์˜ˆ์‹œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

fix : Segmentation fault ํ˜„์ƒ ํ•ด๊ฒฐ

For๋ฌธ์—์„œ ๋ฐฐ์—ด์˜ ์ตœ๋Œ€ ์ธ๋ฑ์Šค๋ฅผ ์ดˆ๊ณผํ•˜์—ฌ ์ ‘๊ทผํ–ˆ๋˜ ๊ฒƒ์„ ์ˆ˜์ •
   - main.c 723์ค„ ์ฐธ๊ณ 

resolved #4431

Ignore File

์ด๋ฆ„ ๊ทธ๋Œ€๋กœ Git์—์„œ ์•„์˜ˆ ์‹ ๊ฒฝ์„ ์“ฐ์ง€ ์•Š์•„๋„ ๋  ํŒŒ์ผ ๋ชฉ๋ก์„ ๋ช…์‹œํ•  ์ˆ˜ ์žˆ๋‹ค. ์ด ํŒŒ์ผ์— ๋ช…์‹œ๋œ ํŒŒ์ผ๋“ค์€ $ git status ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰๋˜๋ฉด ์ถœ๋ ฅ๋˜๋Š” Untracked files ์—๋„ ์ œ์™ธ๋œ๋‹ค.

Ignore file์€ Git repo์—์„œ .gitignore ํŒŒ์ผ์„ ์ƒ์„ฑํ•˜๊ณ , ๋ฌด์‹œํ•  ํŒŒ์ผ(๋””๋ ‰ํ„ฐ๋ฆฌ) ๋ฆฌ์ŠคํŠธ๋ฅผ ํŒŒ์ผ์— ์ž‘์„ฑํ•˜๋ฉด ๋œ๋‹ค. ๊ฐ๊ฐ ๊ฐœํ–‰์œผ๋กœ ๊ตฌ๋ถ„ํ•ด์ค€๋‹ค.

ํ‘œ์ค€์–‘์‹์œผ๋กœ Glob ํŒจํ„ด์„ ์‚ฌ์šฉํ•œ๋‹ค.

๋ฆฌ์ŠคํŠธ ์ค‘์— ๋ฌด์‹œ๋ฅผ ์ทจ์†Œํ•˜๊ณ  ์‹ถ์€ ๊ฒŒ ์žˆ๋‹ค๋ฉด, ์‚ญ์ œํ•˜๊ฑฐ๋‚˜ ๋งจ ์•ž์— #์„ ์ถ”๊ฐ€ํ•ด์ค€๋‹ค.

Github standard

C, Jave ๋“ฑ ๊ฐ ์ฝ”๋“œ ํฌ๋งท๋งˆ๋‹ค ์ปดํŒŒ์ผ ๋“ฑ ์ž‘์—… ์‹œ ์ƒ์„ฑ๋˜๋Š” ๋ถ€์‚ฐ๋ฌผ๋“ค(๋ฐ”์ด๋„ˆ๋ฆฌ ๋“ฑ)์ด ์กด์žฌํ•œ๋‹ค. ํ•˜์ง€๋งŒ, ํ˜•์ƒ๊ด€๋ฆฌ๋Š” ์ฝ”๋“œ ๊ด€๋ฆฌ๋ฅผ ์ฃผ๋กœ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ด๋Ÿฌํ•œ ๋ถ€์‚ฐ๋ฌผ๋“ค์€ ํ•„์š”์—†๋Š” ์กด์žฌ์ด๋‹ค.

๊ทธ๋ž˜์„œ Github์—์„œ๋Š” ๊ฐ ์ฝ”๋“œ ํฌ๋งท ๋ณ„ Ignore file์„ ์ •์˜ํ•˜์—ฌ ์ œ๊ณตํ•œ๋‹ค. ๊ทธ๋ž˜์„œ ๋ณดํ†ต ์—ฌ๊ธฐ์„œ ์ œ๊ณตํ•˜๋Š” Ignore file์„ ๋ฐ”ํƒ•์œผ๋กœ ๊ฐ์ž์˜ ํ™˜๊ฒฝ์— ๋งž๊ฒŒ ์ปค์Šคํ…€ํ•˜์—ฌ ์‚ฌ์šฉํ•œ๋‹ค.

Github ์–‘์‹์„ ์‚ฌ์šฉํ•˜๋ ค๋ฉด ๋‹ค์šด๋กœ๋“œ ๋ฐ›์•„์„œ ์ด๋ฆ„์„ .gitignore ๋กœ ๋ณ€๊ฒฝํ•˜๋ฉด ๋œ๋‹ค.

github/gitignore

C.gitignore

# Prerequisites
*.d

# Object files
*.o
*.ko
*.obj
*.elf

# Linker output
*.ilk
*.map
*.exp

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

# Debug files
*.dSYM/
*.su
*.idb
*.pdb

# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf

์ข‹์€ ์›นํŽ˜์ด์ง€ ์ฆ๊ฒจ์ฐพ๊ธฐ