1. What is Branch branch? My preliminary understanding is that the GitHub repository has a master branch by default, and when we receive a new functional requirement in the Master branch development process, we can create a new branch to synchronize the development without affecting each other, and after the development is completed, the merge merge to the Master Branch master. 2. Branching operations now we need to merge two branches: "Master" and "Gh-pages", before merging, we will first understand a few basic git command ①. Open git shell②. Input command git branch, we can see our current two branch ③. Input command git branch new_branch,
Create a new branch New_branch④. Input command git chekedout gh-pages,
we can switch branches .Or:
Create a new branch and immediately switch to the new branch , and enter the command git checkout-b new_branch_ha⑤.
Merge Branch , enter command git merge gh-pages error! Fatal:refusing to merge unrelated histories.
Google for a moment, find the following explanation * "Git merge" used to allow merging two branches that have no common base by default, which led to a brand new history of an existing project created and then get Pulled by an unsuspecting maintainer, which allowed an unnecessary parallel history merged into the existing project. The Command has been taught not to allow this by default, with an escape hatch "--allow-unrelated-histories" option to be used In a rare event that merges histories of two projects that started their lives independently. * "Git pull" has been taught to pass the "--allow-unrelated-histories" option to underlying "Git merge".
Workaround:Add a sentence after the command.
--allow-unrelated-histories", that is, the complete command is" git merge gh-pages--allow-unrelated-histories ", you can see that the files on the Gh-pages branch are all merged onto the master branch. Next, we need to enter the command" Git Push ", You can see that our code has been synced to the warehouse test.github.com, open the GitHub home page, go to our warehouse test.github.com, you can see the branch gh-pages on the file has been synced over ⑥.
Delete Branch , we just created an extra branch in the 4th step "New_branch_ha" needs to be deleted, we first enter the command "Git branch" to see what the current branch, and then enter the command "
git branch-d new_branch_ha"Delete Branch" New_branch_ha ", finally we enter the command" GIT branch "View branch has been successfully deleted by us.
(This article original, reproduced please indicate the source!!) )
GitHub use (iv)-about branch Branch