Giter Site home page Giter Site logo

git_guide's Introduction

๐Ÿ“– ๊นƒ ๊ฐ€์ด๋“œ (git_guide)

git push / pull ์‰ฝ๊ฒŒ ์„ค๋ช…ํ•˜๊ธฐ

[์ด์Šˆ]

  • git push์˜ ์ •ํ™•ํ•œ ์˜๋ฏธ๊ฐ€ ๋ฌด์—‡์ธ๊ฐ€?
  • git pull์˜ ์ •ํ™•ํ•œ ์˜๋ฏธ๊ฐ€ ๋ฌด์—‡์ธ๊ฐ€?

[๋‹ต๋ณ€]

  • git push์˜ ์ •ํ™•ํ•œ ์˜๋ฏธ๊ฐ€ ๋ฌด์—‡์ธ๊ฐ€?
  • git push๋Š” ์ •ํ™•ํ•˜๊ฒŒ ๋งํ•˜๋ฉด, push๋ฅผ ํ•˜๋ ค๋Š” branch์˜ commit ์ƒํ™ฉ์„ push๋ฅผ ๋‹นํ•˜๋Š” branch์— ๋ฐ€์–ด๋„ฃ๋Š” ์•ก์…˜์ด๋‹ค.
    ๋ฐ€์–ด๋„ฃ์„ ๋•Œ๋Š” ๋‹น์—ฐํžˆ ๋‘ branch์˜ ์ „์ฒด์ ์ธ commit ์ƒํ™ฉ์ด ๊ฐ™์•„์•ผ ํ•˜๊ณ ,
    ๊ฐ™์€ ํŒŒ์ผ์— ๋Œ€ํ•ด์„œ commit ์ƒํ™ฉ์ด ๋‹ค๋ฅธ ํŒŒ์ผ์ด ์žˆ๋‹ค๋ฉด push ํ•˜๋ ค๋Š” branch๊ฐ€ ์šฐ์„ ์‹œ ๋œ๋‹ค. ๋”ฐ๋ผ์„œ, push ๋‹นํ•˜๋Š” branch๋Š” ๋ณ€๊ฒฝ์ ์ด ์žˆ์œผ๋ฉด ์•ˆ๋œ๋‹ค (์žˆ์œผ๋ฉด conflict) conflict์ด ๋‚˜๋Š” ์ด์œ ๋Š” git์ด ๊ฐ™์€ ํŒŒ์ผ์— ๋Œ€ํ•œ ๋‹ค๋ฅธ commit ์ค‘ ์–ด๋Š ๊ฒƒ์„ ๋”ฐ๋ผ์•ผ ํ•˜๋Š”์ง€ ์•Œ ์ˆ˜ ์—†๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.
  • git pull์˜ ์ •ํ™•ํ•œ ์˜๋ฏธ๊ฐ€ ๋ฌด์—‡์ธ๊ฐ€?
  • git pull์€ ์ •ํ™•ํžˆ git fetch + merge ์ด๋‹ค. git fecth๋Š” ๋‹จ์ˆœํžˆ ์†Œ์Šค reposit์—์„œ commit ๋“ค์„ ๊ฐ€์ ธ์˜ค๋Š” ํ–‰์œ„์— ํ•ด๋‹นํ•˜๊ณ 
    merge๋Š” ๊ฐ€์ ธ์˜จ commit๊ณผ ํ•ฉ์น˜๋ ค๋Š” branch์˜ commit์„ ํ•œ๊ตฐ๋ฐ๋กœ ํ•ฉ์น˜๋Š” ๊ฒƒ์„ ์˜๋ฏธํ•œ๋‹ค. (ํ•ฉ์น˜๋Š” ๊ณผ์ •์—์„œ git์ด ํ—ท๊ฐˆ๋ฆด๋งŒํ•œ ์ƒํ™ฉ์ด ๋ฐœ์ƒํ•˜๋ฉด issue/conflict ๋ฐœ์ƒ)
    ๋‹ค์‹œ ๋งํ•ด, git pull ์€ ์†Œ์Šค branch๊ฐ€ ์ฃผ๊ถŒ์ด ์žˆ์–ด์„œ ์—ฌ๊ธฐ์— ๊ธฐ์ค€์„ ๋งž์ถฐ์„œ merge๋ฅผ ์ง„ํ–‰ํ•œ๋‹ค. (๋™์ผ ํŒŒ์ผ์— ๋Œ€ํ•ด ๋ณ€๊ฒฝ์ ์ด ์žˆ๋‹ค๋ฉด ์†Œ์Šค branch์˜ ๋ณ€๊ฒฝ์ ์„ ๋”ฐ๋ฅธ๋‹ค)

Conflict์ด ๋‚˜๋Š” ๊ธฐ์ค€์€ ๋ฌด์—‡์ธ๊ฐ€?

[์ด์Šˆ]

  • Remote reposit A ์ƒ์„ฑ โ†’
  • remote A ์—์„œ a.txt ์ƒ์„ฑ ํ›„ commit โ†’
  • local ์—์„œ reposit A clone โ†’
  • remote A ์—์„œ b.txt ์ƒ์„ฑ ํ›„ commit
  • local A ์—์„œ c.txt ์ƒ์„ฑ ํ›„ commit
  • ์—ฌ๊ธฐ์„œ local A ์—์„œ remote A๋กœ push ํ•˜๋ ค๊ณ  ํ•˜๋ฉด ๊ณผ์—ฐ conflict์ด ๋‚˜๋Š”๊ฐ€?
  • conflict์ด ๋‚œ๋‹ค๋ฉด local A์— ์—†๊ณ  remote A์— ์กด์žฌํ•˜๋Š” b.txt ๋•Œ๋ฌธ์ธ๊ฐ€? ์•„๋‹ˆ๋ฉด ๋ฐ˜๋Œ€์ธ c.txt ๋•Œ๋ฌธ์ธ๊ฐ€?

[๋‹ต๋ณ€]

  • ์—ฌ๊ธฐ์„œ local A ์—์„œ remote A๋กœ push ํ•˜๋ ค๊ณ  ํ•˜๋ฉด ๊ณผ์—ฐ conflict์ด ๋‚˜๋Š”๊ฐ€?
  • ๋งž๋‹ค. conflict์ด ๋‚œ๋‹ค. git push๋ฅผ ํ•˜๊ธฐ ์ „์—๋Š” git pull(fetch+merge) ๋ฅผ ํ†ตํ•ด push ํ•˜๋Š” branch์™€ push ๋‹นํ•˜๋Š” branch์˜ commit ์ƒํ™ฉ์„ ๋งž์ถœ ํ•„์š”๊ฐ€ ์žˆ๋‹ค
    local A๋Š” git์ด a.txt ์™€ c.txt ํŒŒ์ผ๋“ค์„ ํŠธ๋ž˜ํ‚น ์ค‘์ด๋ฉฐ, remote A๋Š” git์ด a.txt์™€ b.txt ์— ๋Œ€ํ•ด ํŠธ๋ž˜ํ‚น ์ค‘์ด๋‹ค. ๊ณ ๋กœ ์ „์ฒด์ ์ธ commit ์ƒํ™ฉ์ด ๊ฐ™์ง€ ์•Š์œผ๋ฏ€๋กœ push๊ฐ€ ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค
  • ๊ทธ๋ ‡๋‹ค๋ฉด git pull ์€ issue๊ฐ€ ๋‚˜์ง€ ์•Š๋Š”๊ฐ€?
  • ์•„๋‹ˆ๋‹ค. issue๊ฐ€ ๋‚œ๋‹ค. ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ local A๋Š” a.txt ์™€ c.txt๋ฅผ remote A๋Š” a.txt ์™€ b.txt ๋ฅผ ํŠธ๋ž˜ํ‚น์ค‘์ด๋ฏ€๋กœ ํŒŒ์ผ ํŠธ๋ž˜ํ‚น์— ๋Œ€ํ•œ conflict์€ ์—†์ง€๋งŒ ์ „์ฒด์ ์ธ commit ์ƒํ™ฉ์ด ๋‹ค๋ฅด๋ฏ€๋กœ issue๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค๊ณ  ๋ณผ ์ˆ˜ ์žˆ๋‹ค. ํ•˜์ง€๋งŒ ํŒŒ์ผ conflict์ด ์•„๋‹ˆ๋ฏ€๋กœ git์˜ ๊ธฐ๋ณธ์„ค์ •์„ ๋ฐ”๊ฟ”์„œ rebase ์ž๋™ ๊ธฐ๋Šฅ (git config pull.rebase true)์„ ํ‚ค๋ฉด git์ด ์ž๋™์œผ๋กœ issue๊ฐ€ ๋‚œ ๋ถ€๋ถ„์„ rebase ํ•˜๊ณ  merge๋ฅผ ์‹œ์ผœ์ฃผ๋ฉด์„œ pull์„ ํ•ด์ค€๋‹ค.

git_guide's People

Contributors

nyeongna avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.