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
I want to create a new branch
# checkout new branch based upon the current branch
git checkout -b <new branch name>
If I create a new branch, do I have to copy that files; Or are they copied automatically if I create a new branch?
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.
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)?
This is what's the checkout -b
does - switch you to the new branch