init-status-add-commit-log-stage-repository

init

ํ”„๋กœ์ ํŠธ ํด๋”๋ฅผ ๋ฒ„์ „๊ด€๋ฆฌ ํ•˜๊ฒ ๋‹ค.

git

์ด๋ผ๊ณ  ์ž…๋ ฅํ•˜๋ฉด

usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]

These are common Git commands used in various situations:

start a working area (see also: git help tutorial)
   clone      Clone a repository into a new directory
   init       Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)
   add        Add file contents to the index
   mv         Move or rename a file, a directory, or a symlink
   reset      Reset current HEAD to the specified state
   rm         Remove files from the working tree and from the index

examine the history and state (see also: git help revisions)
   bisect     Use binary search to find the commit that introduced a bug
   grep       Print lines matching a pattern
   log        Show commit logs
   show       Show various types of objects
   status     Show the working tree status

grow, mark and tweak your common history
   branch     List, create, or delete branches
   checkout   Switch branches or restore working tree files
   commit     Record changes to the repository
   diff       Show changes between commits, commit and working tree, etc
   merge      Join two or more development histories together
   rebase     Reapply commits on top of another base tip
   tag        Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)
   fetch      Download objects and refs from another repository
   pull       Fetch from and integrate with another repository or a local branch
   push       Update remote refs along with associated objects

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.

์ด๋ผ๊ณ  ๋– ์„œ ๋ช…๋ ฅ์–ด๋“ค์„ ๋‹ค ํ™•์ธ ํ•  ์ˆ˜ ์žˆ๋‹ค.

git init 
# Initialized empty Git repository in dr/.git/
ls -al

.git ์ด๋ผ๋Š”๊ฒŒ ์ƒ๊ฒผ๋‹ค๋Š” ๊ฑธ ํ™•์ธ ํ•  ์ˆ˜ ์žˆ๋‹ค.

status

# vim์„ ์ด์šฉํ•ด fi.txt๋ฅผ ์ˆ˜์ •ํ•˜๊ฒ ๋‹ค.
vim f1.txt

# ์ž…๋ ฅ์ƒํƒœ๋กœ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋‹ค.
i

# esc๋ฅผ ๋ˆ„๋ฅด๋ฉด ์ž…๋ ฅ์ƒํƒœ๋ฅผ ๋น ์ ธ๋‚˜๊ฐˆ ์ˆ˜ ์žˆ๋‹ค.

# ์ž‘์„ฑ๋‚ด์šฉ์„ ์ €์žฅํ•˜๊ณ  vim์„ ์ข…๋ฃŒํ•˜๊ณ  ์‹ถ๋‹ค.
:wp

# ํŒŒ์ผ์ด ์žˆ๋Š”์ง€ ํ™•์ธํ•˜์ž
ls -al

# ํŒŒ์ผ ๋‚ด์šฉ์„ ํ™•์ธํ•œ๋‹ค.
cat f1.txt

txtํŒŒ์ผ์„ ๋งŒ๋“ค๊ณ  ์•ˆ์— ๋‚ด์šฉ๋„ ๋„ฃ์–ด์คฌ๋‹ค.

git status

๋ฅผ ์ž…๋ ฅํ•˜๋ฉด

On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        f1.txt

nothing added to commit but untracked files present (use "git add" to track)

untracked - ์ถ”์ ๋˜๊ณ  ์žˆ์ง€ ์•Š์Œ์„ ๋งํ•œ๋‹ค. ํด๋”์— ์ƒํƒœ๋ฅผ ์•Œ ์ˆ˜ ์žˆ๋‹ค.

add (stage area)

์ด ํŒŒ์ผ์„ ๊ด€๋ฆฌํ•ด~ commit ๋Œ€๊ธฐ์ƒํƒœ - stage area

์—ฌ๋Ÿฌ๊ฐœ์˜ ํŒŒ์ผ์„ commit ํ•  ๋•Œ / ์„ ํƒ์ ์œผ๋กœ commit ํ•  ๋•Œ ์œ ์šฉํ•˜๊ธฐ ๋•Œ๋ฌธ์— add ๋Š” ๊ผญ ํ•„์š”ํ•˜๋‹ค.

git add f1.txt

commit

๋ฒ„์ „์œผ๋กœ ๋งŒ๋“ค์–ด ์ €์žฅํ•˜๊ธฐ

์ด์ „์œผ๋กœ ๋Œ์•„๊ฐˆ ์ˆ˜ ์žˆ๊ณ  ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ํ™•์ธ ํ•  ์ˆ˜ ์žˆ๋‹ค.

๋ฒ„์ „ - ์˜๋ฏธ์žˆ๋Š” ๋ณ€ํ™”

On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

ํ˜„์žฌ์ƒํƒœ๊ฐ€ add๋กœ ํŠธ๋ ˆํ‚น ๋œ ์ƒํ™ฉ์ด๋ผ๋Š” ๊ฑธ ์•Œ ์ˆ˜ ์žˆ๋‹ค.

์ด๋ฆ„ ์…‹ํŒ…

git config --global user.name sla 
git config --global user.email seula00027@gmail.com

๋”ฑ ํ•œ๋ฒˆ๋งŒ ํ•˜๋ฉด ๋œ๋‹ค.

commit ํ•˜๊ธฐ

git commit

์„ ํ•˜๋ฉด vim์ด ์‹คํ–‰์ด ๋œ๋‹ค.

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch master
#
# Initial commit
#
# Changes to be committed:
#       new file:   f1.txt

ํ˜„์žฌ ๋ฒ„์ „์˜ ๋ฉ”์‹œ์ง€๋ฅผ ์“ฐ์ž. ์™œ ๋ณ€๊ฒฝ์ด ๋˜์—ˆ๋Š”์ง€ 'ใ…'/

# ์ž…๋ ฅ์ƒํƒœ๋กœ ๋ฐ”๊พผ๋‹ค.
i

# ์ปค๋ฐ‹ ๋ฉ”์‹œ์ง€๋ฅผ ์ž…๋ ฅํ•œ๋‹ค. 

#esc๋ฅผ ๋ˆ„๋ฅธ๋‹ค

#์“ด ๋‚ด์šฉ์„ ์ €์žฅํ•˜๊ณ  vim์ข…๋ฃŒํ•˜๊ธฐ
:wq

log

git log
commit 8617324471f8df5dc36e62c20e82609841745c8f (HEAD -> master)
Author: sla <blabla>
Date:   Wed May 22 18:40:05 2019 +0900

    1

์ปค๋ฐ‹๋ฉ”์‹œ์ง€์™€ ํ•จ๊ป˜ ํ™•์ธ ํ•  ์ˆ˜ ์žˆ๋‹ค.

๋ณต์Šต

# f2.txt๋ฅผ ๋งŒ๋“ค๊ณ  ์ปค๋ฐ‹ํ•˜์ž
# vim ํŒŒ์ผ์„ ๋งŒ๋“ค๊ณ  ์“ฐ๋Š” ๊ฑธ ๋™์‹œ์— ํ•  ์ˆ˜ ์žˆ๋‹ค. 
cp f1.txt f2.txt

# ์ž…๋ ฅ์ƒํƒœ๋กœ ๋งŒ๋“ ๋‹ค
i
# ์“ฐ๊ณ ์ž ํ•˜๋Š” ๋‚ด์šฉ์„ ์ž…๋ ฅํ•œ ๋’ค
# Esc๋ฅผ ๋ˆ„๋ฅธ๋‹ค.
# ์ €์žฅํ›„ vim ์ƒํƒœ ๋ฒ—์–ด ๋‚˜๊ธฐ
:wq
# ์ž˜ ๋งŒ๋“ค์–ด์กŒ๋Š”์ง€ ํ™•์ธํ•˜๊ธฐ
ls -al
# ๋‚ด์šฉ ํ™•์ธ
cat f1.txt
# git ๋ฒ„์ „๊ด€๋ฆฌ ์ƒํƒœ ํ™•์ธํ•˜๊ธฐ Untracked ํ™•์ธ
git status

# git addํ•˜๊ธฐ
git add
# ํ™•์ธ
git status 

# commit
git commit 
# ๋ฉ”์‹œ์ง€ ์ž…๋ ฅ
i 
# ๋ฉ”์‹œ์ง€ ์ž‘์„ฑํ›„ Esc
# ์ €์žฅํ›„ vim ์ƒํƒœ ๋น ์ ธ ๋‚˜์˜ค๊ธฐ
:wq

# commit ํ›„ ํ™•์ธํ•˜๊ธฐ
git log

stage, repository

stage: add๋ฅผ ์™„๋ฃŒํ•˜๊ณ  commit ํ•˜๊ธฐ์ „ ํŒŒ์ผ๋“ค์ด ๊ฐ€๋Š” ๊ณณ

repository: commitํ•œ ํŒŒ์ผ๋“ค์ด ๊ฐ€๋Š” ๊ณณ

Last updated

Was this helpful?