Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Git/Github] 스터디 실습 #2

Open
1 of 9 tasks
Cotidie opened this issue Mar 26, 2022 · 0 comments
Open
1 of 9 tasks

[Git/Github] 스터디 실습 #2

Cotidie opened this issue Mar 26, 2022 · 0 comments

Comments

@Cotidie
Copy link
Member

Cotidie commented Mar 26, 2022

Git/Github

Git != Github

image

  • Git: 로컬 버전 관리 시스템
  • Github: Git에 대한 클라우드 저장소

add, commit, push, pull

Git Command Simplified Git Command Flow
image Untitled
  • add: 버전 관리할 대상으로 지정 (Modified -> Staged)
  • commit: 새로운 버전을 갱신 (Staged -> Commit)
  • push: Github 등 클라우드에 업로드
  • pull: Github 등 클라우드로부터 최신 버전을 다운로드 (동기화)

rebase

image
Branch의 base가 되는 commit을 변경하는 커맨드

  • 충돌을 미리 해결할 수 있다. (Fast-Forward)
  • 중간에 PR을 올려도 개발을 계속할 수 있다.
  • 개발 중간에 최신 버전으로 동기화 할 수 있다.

reset

image
특정 커밋 시점으로 되돌리는 커맨드

  • soft: 되돌린 시점까지 commit 내역 유지
  • mixed: 되돌린 시점까지 commit 삭제
  • hard: 되돌린 시점으로 파일/변경내역까지 삭제

실습

  • 실수로 main 브랜치에 commit한 경우 (reset, stash, pop)
  • 실수로 main 브랜치에 commit하고 push까지 한 경우 (cherry-pick, revert)
  • 개발 중간에 PR을 올리는 경우 (branch, rebase)
  • commit을 합치고자 하는 경우 (interactive rebase, squash)
  • commit을 쪼개려는 경우 (interactive rebase, reset mixed)
  • 충돌 미리 해결하기 (rebase)
  • 특정 지점으로 Rebase (tag)
  • 실수로 reset --hard 후 push까지 한 경우 (reflog)
    • git rebase -i -> git push -f
    • git reset --hard -> git push -f
  • main 브랜치 push 막기 (branch protection)
@Cotidie Cotidie closed this as completed Jul 13, 2024
@Cotidie Cotidie reopened this Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant