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?