本文介绍了GIT-分支,什么是分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是GIT的新手。
我想创建一个新分支:该存储库中有3个文件。



如果我创建一个新分支,是否必须复制该文件?还是如果我创建新分支会自动复制它们?



当我想在分支上工作时,是否必须在开始工作(打开该文件)之前切换到GIT内部的那个分支?
非常感谢您的帮助

解决方案


 #根据当前分支签出新分支
git checkout -b<新分支名> ;




新分支是当前分支的 Full 副本。

为了理解为什么您需要知道git中的分支。




GIT中的分支是什么?

Git中的分支只是一个轻量级可移动提交指针。

这是结帐- b 可以-切换到新分支


I am new to GIT.I want to create a new branch: I have 3 files inside that repository.

If I create a new branch, do I have to copy that files; Or are they copied automatically if I create a new branch?

When I want work on the branch, do I have to switch to that branch inside GIT, before I start to work (opening that files)?Thank you very much for your help

解决方案
# checkout new branch based upon the current branch
git checkout -b <new branch name>


The new branch is a FULL copy to the current branch.
In order to understand why you need to know what is branch in git.


What is branch in GIT?

A branch in Git is simply a lightweight movable pointer to commit.
Here is a very short and simple post about it

In other words:

Branch in git is simply a pointer to a commit.
As you can see in the image below (taken from the post mentioned above), all the branches are pointing to commit B + the delta which was added to them.

When you create branch git creates a file and writing the commit id to this file.

This is what's the checkout -b does - switch you to the new branch

这篇关于GIT-分支,什么是分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 21:12