Skip to content

Branch #6

@bitfishxyz

Description

@bitfishxyz

show branches list

git branch

create new brancj

git branch newBranchName

change branch

git checkout branchName

merge branch

git merge targetBranchName

if it is comfilct

  • master branch
    • commit 1
    • commit 2
    • commit fromMasterBran
  • test branch
    • commit 1
    • commit 2
    • commit fromTestBran

they all change hello.txt in third commit change, how to deal with when you are trying git merge testBranch?

it will fail merge, and change you hello.txt in working dir.

<<<<<<< HEAD
bbbbb
=======
aaaa
>>>>>>> testBran

you have to add a commit to master branch till this comfilct is not exist.

  • master branch
    • commit 1
    • commit 2
    • commit fromMasterBran
    • commit checkout conflict

then git merge testBran

  • master branch
    • commit 1
    • commit 2
    • commit fromMasterBran
    • commit fromTestBran
    • commit checkout conflict
  • test branch
    • commit 1
    • commit 2
    • commit fromTestBran

git only saves changes, do not let them conflict before merge them.

  • commit fromMasterBran mean add changes to hello.txt compare to commit 2
  • commit fromTestBran mean add changes to hello.txt compare to commit 2
  • commit checkout conflict mean figure conflict to above two compare to commit 2

It's fine!

delete branch

normal delete

git branch -d branName

force delete

git branch -D branName

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions