π
git νΉμ§?
- λΆμ°ν λ²μ κ΄λ¦¬ μμ€ν ( μ€μ κ΄λ¦¬ X )
- λ³λ ¬ μμ κ°λ₯
- κ°λ³κ³ λΉ λ₯΄λ€ !
- λ°μ΄ν° 보μ₯
- Staging area( μ€λΉ μμ )
- μ€ν μμ€
git μ€μΉ λ° νμΈ
Terminal
β git
Teminal
β git --version
: git λ²μ νμΈνκΈ°git μ΄κΈ° μ€μ
μ¬μ©μ μ€μ
Teminal
β git config --global [user.name](http://user.name) 'username'
Teminal
β git config --global [user.](http://user.name)email [ email adress ]
--global
μμ΄ git config [user.name](http://user.name)
μ²λΌ μμ± μ νλ‘μ νΈ λ§λ€ μλ‘ μ§μ νμμ€μ μ 보 νμΈ
Terminal
β git config --list
git life cycle
π
untracked
-unmodified
-modified
-staged
init
-add
-commit
/log
git status
add
λ‘ staging λμ§ μμκ³ , μμ§ commitλμ§ μμ μνgit command
git init
: νμ¬ λλ ν 리λ₯Ό git repositoryλ‘ μ€μ git add
: νμΌμ μ€λΉ μμμΌλ‘ 보λ΄κΈ°, option λ°λμ μ§μ !git add .
: ν΄λΉ λλ ν 리 λ΄ λͺ¨λ λ³κ²½ νμΌ ν¬ν¨νλ μ΅μ
git add [file_name]
: ν΄λΉ νμΌ 1κ°μ λ³κ²½ λ΄μλ§ ν¬ν¨git reset [file_name]
: add λͺ
λ Ή μ·¨μνκΈ°git restore --staged [file_name]
: add λͺ
λ Ή μ·¨μνκΈ°git reset HEAD
: staging νμΌ λͺ¨λ μ·¨μgit status
: staging areaμ μ΄λ€ νμΌμ΄ λ³κ²½λμλμ§ λ± νμΌμ μν νμΈgit commit
: 무μμ μμ νκ³ μΆκ°νλμ§ λ©μμ§λ₯Ό λ¨κΈ°κ³ μ μ₯μμ μ μ₯git commit
: μ»€λ° λ©μμ§λ₯Ό μ
λ ₯νλ μλν°κ° μ΄λ¦Όgit commit -m 'message'
: message λΆλΆμ μ»€λ° λ©μμ§λ₯Ό λͺ
λ Ήμ΄μ μ§μ μ§μ git commit --amend
: μ΄μ μ λ©μμ§μ μ€νλ λλ½μ΄ μμ κ²½μ° μ μ νλ λͺ
λ Ήμ΄git log
: μ μ₯μ λ°μ λ΄μ νμΈgit branch
π λ 립μ μΌλ‘ μ΄λ€ μμ μ μ§ννκΈ° μν κ°λ μΌλ‘ λ€λ₯Έ Branchμ μν₯μ λ°μ§ μμ
- main/ master branch: λ°°ν¬ν μ μλ μμ€μ μμ μ μΈ branch
- topic branch: κΈ°λ₯ μΆκ°λ λ²κ·Έ μμ κ³Ό κ°μ λ¨μ μμ μ μν branch
git branch
: νμ¬ λΈλμΉ νμΈgit branch [branch_name]
: λΈλμΉ μμ±git checkout [branch_name]
: λΈλμΉ μ νgit checkout -b [branch_name]
: λΈλμΉ μμ± ν ν΄λΉ λΈλμΉλ‘ μ νgit merge
git merge [branch_name]
: λΈλμΉ λ³ν©git branch --merged
: λ³ν©λ λΈλμΉ νμΈgit branch -d [branch_name]
: μ¬μ©μ λ§μΉ λΈλμΉ μμ git merge --abort
: λ³ν© μ·¨μgit commit -a -m 'message'
: message λΆλΆμ λ©μμ§λ₯Ό λͺ
λ Ήμ΄μ μ§μ μμ±, λ³ν© μ·¨μgit conflict
π conflict ν΄κ²°νκΈ°
- μΆ©λμ΄ μΌμ΄λ νμΌμ λ΄μ© μμ ν
<<<<<<<
,=======
,>>>>>>>
κ° ν¬ν¨λ ν μμ git add
,git commit
κ³Όμ μ κ±°μ³ λ€μgit merge
μν !
git repository
π μΈν°λ·μ΄λ λ€νΈμν¬ μ΄λκ°μ μλ μ격 μ μ₯μ
git clone
git clone [repository_name] [repository_url]
: μ격 μ μ₯μ λ΄μ© 볡μ¬[repository_name]
: 볡μ¬ν΄ μ¬ μ격 μ μ₯μμ μ΄λ¦[repository_url]
: 볡μ¬ν μ격 μ μ₯μμ URLgit remote
git remote add [repository_name] [repository_url]
: λ‘컬 μ μ₯μμ μ격 μ μ₯μ μ°κ²°git remote -v
: μ§μ λ μ μ₯μμ μ΄λ¦κ³Ό μ£Όμ νμΈgit pull
git fetch
git pull
: μ격 μ μ₯μμμ λ°μ΄ν° κ°μ Έμ€κΈ° ( + merge κ°λ
)git pull [repository_name] [branch_name]
:git fetch
: μ격 μ μ₯μμμ λ°μ΄ν° κ°μ Έμ€κΈ° ( μ§νμ€μΈ μμ
λ§λ¬΄λ¦¬ ν λ³ν©νμ )git push
git push [repository_name] [branch_name]
: λ‘컬 μ μ₯μ μμ
λ΄μ© μ격 μ μ₯μμ λ°μ