GitHub merge, branch, checkout

Chanyong·2021년 11월 21일
0

TIL

목록 보기
1/7

새로운 브랜치 생성

git branch <branch_name>

브랜치 전환 (2가지)

git checkout <branch_name>
git switch <branch_name>

브랜치 A에서 브랜치 B로 전환할 때, A에서 작업했던 내용은 git add 및 git commit 까지 해줘야한다. 그렇지 않으면 작업내용이 전환된 브랜치(B)까지 옮겨간다.


브랜치 되돌리기 (git reset, git revert)

1.

git reset --hard [commit_ID] 

commit_ID로 HEAD를 바꿔주고, 이 이후에 했던 commit들은 제거한다.

2.

git revert [commit_ID]

commit_ID 내용으로 새로운 commit을 작성하여 HEAD를 위치시키고, commit 이력은 제거하지 않는다.


브랜치 병합 (git merge)

브랜치 A와 B를 병합시킬 때,

git merge [branch_name]

병합 시에 충돌이 생기면 해당 파일 내용에 로그가 생기고, 이것들을 수정해준 뒤

git add
git commit 

해주면됨.


브랜치 제거 (git branch -d)

git branch -d [branch_name]

Reference

누구나 쉽게 이해할 수 있는 Git 입문 https://backlog.com/git-tutorial/kr/stepup/stepup2_6.html

profile
AI Accelerator 연구

0개의 댓글