[CS] Git Branch Day-89

cptkuk91·2022년 3월 27일


목록 보기

Git is the best tool for developers to collaborate.

When developing software, developers share the same source code.

Branch is a feature that allows multiple developers to work on different tasks at the same time.

What is Branch?

You can do multiple tasks at the same time without affecting other people's work.

A branch is created in master or main.

A branch is an independent workspace. You can create a new branch by merging the changed part with another branch.

Changes can be applied by merging each task after working in a branch.

Advantages of Branch

  • It allows you to do multiple tasks at the same time in the same code.
  • You can revert to the code at a specific point in time.
  • You can code independently without affecting other branches.

Branch type

  • Integration Branch
    Deploy source code,

When you create a Github Repository, a main branch is created by default. Integration Branch stands for main.

It contains the code in a state where all functions are working well.

  • Feature Branch
    A branch for adding new features and fix errors.

A feature branch is merged with another branch when one task is completed.

Branch Command Suite

  • create new branch
git branch 새로운 브랜치 이름
  • After creating a new branch, move to the branch
git switch -c 새로운 브랜치 이름

git checkout -b 새로운 브랜치 이름
  • Check Branch List
git branch
  • Check the list of branch and Check recent commits of branch
git branch -v
  • Delete Branch
git branch -d 삭제할 브랜치 이름
  • Branch Conversion
git switch 브랜치 이름

git checkout 브랜치 이름
  • Merge Branch
git checkout master

git merge dev

Branch workflow

Fork, Clone

You can copy the Origin Repository through Fork and download it to Local Storage through Clone.

git checkout -b (New Branch)

Create a Branch and go to the Branch you created.

git checkout -b dev

You can create dev branch and change the repository to dev

git branch

You can check the list of branches.

git checkout (Branch Name)

You can go to (Branch Name).

It is used when moving to the branch that will be the basis before merging.

git merge (Branch Name1)

To merge Branch Name2 with Branch Name1, move to Branch Name1 and use the git merge Branch Name2 command to merge.

git push origin (Branch Name)

Use push to upload local work to the github repository.

메일은 매일 확인하고 있습니다. 궁금하신 부분이나 틀린 부분에 대한 지적사항이 있으시다면 언제든 편하게 연락 부탁드려요 :)

0개의 댓글