[CS] Git Branch Day-89

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.

좋은 웹페이지 즐겨찾기