Cannot switch branches - "Error: unprocessed tree working files ..." should I do git add?

I have this in my .gitignore file:

/nbproject/ /app/runtime/ /app/runtime/application.log* /app/runtime/error.log* /app/config/localdev.php* .DS_Store 

1) I have a checkout for the master branch , and then check again, go back to the dev branch .

2) As soon as I returned to the dev branch , I lost all / nbproject / files and all /app/config/localdev.php! And maybe others, but since they are created automatically using the PHP version of uppon runtime, I can’t say!

3) Then I will return to the main branch , and I received these files there.

4) I copied these files somewhere else, and I switched back to the dev branch .

5) I put these missing files back in / nbproject / folder.

Now, if I try to switch to the master branch, I get the following:

 Error: The following untracked working tree files would be overwritten by checkout: nbproject/private/config.properties nbproject/private/private.properties nbproject/private/private.xml nbproject/project.properties nbproject/project.xml Please move or remove them before you can switch branches. Aborting 

I know that I should possibly do git add . to move these files to the repository, which I don’t understand:

Why does git throw this message if I had nbproject / ignored long before these git output commands?

Question:

The point is to ignore these files. Both on the host and on dev. My question is: how can I fix this so that:

a) First: get those files (those on gitignore) back to dev?

b) Second: take steps to avoid this conflict again.

+4
source share
2 answers

Steps taken to resolve the problem. Credits go: jszakmeister

1) I cloned the project to another place.

2) I have a master on this clone.

3) Put gitior in the master, as it should have been from the very beginning: git show dev: .gitignore> .gitignore

4) I deleted the files from the tree by doing git rm "all files where gitignore one by one"

5) I added the .gitignore file to the repo.

6) fix it

7) go back to the original repo and do:

8) git fetch / path / to / fix-project master: master

9) git check master, and I got: Switched to the 'master' branch. Your branch is ahead of the “hub / master” by 1 commit. this is my remote main branch.

10) Given to the remote master.

11) checkout dev again

+3
source

You can track them in another thread. Or you can add --force to the checkout command to zap files with what has ever been a wizard. Or you can git clean -xdf before checking the wizard to lock files from the working directory.

+5
source

All Articles