I don't know how it works after creating the git branch master origin/master branch.

Asked 2 years ago, Updated 2 years ago, 50 views

I cloned the develop branch, so I executed the following command to drop the master of the remote branch to the local branch.

Does this mean that you create a master branch locally and merge remote branches there?

I am not used to using git yet, so I would appreciate it if you could tell me more about it.
Thank you for your cooperation.

Synchronize remote branches.
git fetch
# Check the fetch remote branch
git branch-r
git checkout-b master origin/master

Add

Checkout is just switching branches, so I personally think the following is the content that I am concerned about.
I heard that the master is pulled from the develop branch and the master of the remote repository is pulled, and the pull is fetch+merge, so I think merge is working. What do you think?

 git branch master origin/master

The situation is that I cut the branch named master from git checkout-b master origin/master while I was in the develop branch and pulled it, but as far as git log shows, there was no evidence that the remote master was merged into the local master branch.

I think it has the same meaning as this, but if you do this, a branch with a commit below the specified commit log will be created.
If you set this to origin/master, a branch is created from the master latest commit log of the remote repository.
This will probably be a branch that is completely independent of development.
I wonder if it's going to have the image of a double pillar.Probably.

// Create a branch with a starting point
git branch <branch><commit>

See also

If you look at the article below, it says that the above is merging.
https://shu223.hatenablog.com/entry/20130115/1367342778

It has nothing to do with the question, but what should I do if I make a mistake in the parent branch derived from git checkout-b master origin/master and develop it as it is? https://www.granfairs.com/blog/staff/git-mistake-parent-branch

git

2022-09-30 19:53

1 Answers

git checkout is a branch-switching command, and you must run git merge to merge.

The git checkout-b master origin/master you ran switches to the local branch "master" based on the remote branch "origin/master", but it has -b so if the local branch does not exist, create it on the spot…

In addition, git siwtch is currently recommended instead of git checkout.

A side story

I recommend that you refer to the manual first if there is anything you don't understand about the command, not just this Git.With Git, you can use the githelp command to learn how to use it just like the man manual.

Example: git help checkout

for checkout


2022-09-30 19:53

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.