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.txttxtํ์ผ์ ๋ง๋ค๊ณ ์์ ๋ด์ฉ๋ ๋ฃ์ด์คฌ๋ค.
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.txtcommit
๋ฒ์ ์ผ๋ก ๋ง๋ค์ด ์ ์ฅํ๊ธฐ
์ด์ ์ผ๋ก ๋์๊ฐ ์ ์๊ณ ๋ณ๊ฒฝ์ฌํญ์ ํ์ธ ํ ์ ์๋ค.
๋ฒ์ - ์๋ฏธ์๋ ๋ณํ
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์ข
๋ฃํ๊ธฐ
:wqlog
git logcommit 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 logstage, repository
stage: add๋ฅผ ์๋ฃํ๊ณ commit ํ๊ธฐ์ ํ์ผ๋ค์ด ๊ฐ๋ ๊ณณ
repository: commitํ ํ์ผ๋ค์ด ๊ฐ๋ ๊ณณ
Last updated
Was this helpful?