Posts 😸 [Git] git add -p μ˜΅μ…˜
Post
Cancel

😸 [Git] git add -p μ˜΅μ…˜

◻️ Goal

  • git add μ˜΅μ…˜ μ—¬λŸ¬κ°€μ§€ μ‚΄νŽ΄λ³΄κΈ°
  • μ˜΅μ…˜μ„ 톡해 add ν•˜λ €λŠ” 각 파일의 변경사항을 ν™•μΈν•œ λ’€ μŠ€ν…Œμ΄μ§• 할지 κ²°μ •ν•  수 μžˆλ‹€.
  • Stage this hunk [y,n,q,a,d,s,e,?] λͺ…λ Ήμ–΄λ₯Ό μ‚¬μš©ν•  수 μžˆλ‹€.
  • 이 쀑 자주 μ‚¬μš©λ˜λŠ” y, n, q λͺ…λ Ήμ–΄λ§Œ μ•Œκ³  μžˆμ–΄λ„ μΆ©λΆ„ν•˜λ‹€.



◻️ git add -p

git add -p λ₯Ό μ‚¬μš©ν•˜κ²Œ 되면, ν˜„μž¬ λ³€κ²½λœ μ½”λ“œλ“€μ˜ νŒŒμΌλ“€μ„ ν•˜λ‚˜μ”© 보여주고 ν•΄λ‹Ή νŒŒμΌμ„ μŠ€ν…Œμ΄μ§€μ— 올릴 것인지, μ˜¬λ¦¬μ§€ μ•Šμ„ 것인지 λ°”λ‘œ 선택할 수 μžˆλ‹€.

1
2
3
    > git status     (λ³€κ²½λœ 파일 μƒνƒœλ³΄κΈ°)
    > git diff       (μŠ€ν…Œμ΄μ§€μ— μ˜¬λΌκ°€μ§€ μ•Šμ€ νŒŒμΌλ“€μ˜ 변경사항 보기)
    > git add        (μŠ€ν…Œμ΄μ§• ν•˜κΈ°) or git checkout --파일λͺ…


μœ„μ˜ μ„Έ 가지 과정을 git add -p둜 ν•œ λ²ˆμ— 진행할 수 있게 λœλ‹€.


◻️ hunk λͺ…λ Ήμ–΄ λͺ¨μŒ

  • hunk: μŠ€ν…Œμ΄μ§€μ— 올라갈 수 μžˆλŠ” ν•˜λ‚˜μ˜ λ‹¨μœ„
1
2
3
4
5
6
7
8
9
10
11
12
13
14
    y - stage this hunk
    n - do not stage this hunk
    q - quit; do not stage this hunk or any of the remaining ones
    a - stage this hunk and all later hunks in the file
    d - do not stage this hunk or any of the later hunks in the file
    g - select a hunk to go to
    / - search for a hunk matching the given regex
    j - leave this hunk undecided, see next undecided hunk
    J - leave this hunk undecided, see next hunk
    k - leave this hunk undecided, see previous undecided hunk
    K - leave this hunk undecided, see previous hunk
    s - split the current hunk into smaller hunks
    e - manually edit the current hunk
    ? - print help

Reference- Siyoon210 λ‹˜μ˜ λΈ”λ‘œκ·Έ

This post is licensed under CC BY 4.0 by the author.

β˜•οΈ [Java] 30일 μ•ˆμ— 기초 λ–ΌκΈ°/ DAY-07

πŸ‘€ [Today I Learned] 20210514_TIL