Git a new file appears in all branches

I thought that a file created on one branch will not appear in any other branches until I generate or redo the branch?

Example:

I have two branches:

  • master
  • new_contact_page

I am browsing the new_contact_page branch.

$ git checkout new_contact_page 

Then I create a new file.

 $ vi contact_page.html 

Without any Git commands, I return to the Master branch.

 $ git checkout master 

Then I see that this contact_page.html file is also in the Wizard branches.

 $ ls (contact_page.html shows up in the list!) 

Should the file exist only in the new_contact_page branch?

+4
source share
2 answers

Git will never touch files that are not actually in your repository. (files without a trace)

First you need the git add and git commit file (in one branch).

+5
source

It is important here to understand the index (or intermediate area) .
Until you put the files (git add), they remain "untracked" (or "private") and will not be changed using the "git checkout".

This is different from the β€œuninstalled” one, which refers to a tracked file (previously committed to the local Git repository) with local changes not yet added to the index.

You can read more in. You could come up with Git (and maybe you already have one!) "

+1
source

Source: https://habr.com/ru/post/1433244/


All Articles