I have this on my .gitignore file:
/nbproject/
/app/runtime/
/app/runtime/application.log*
/app/runtime/error.log*
/app/config/localdev.php*
.DS_Store
1)
I have checkout to master branch and then, checkout again, back to dev branch.
2)
Once I got back to dev branch, I lost all /nbproject/ files and all /app/config/localdev.php as well !!!
And perhaps the others, but since they are autogenerated by php framework uppon runtime, I can’t really tell!
3)
I then switch back to the master branch and I got those files there.
4)
I’ve copy those files somewhere else, and I’ve switched to dev branch again.
5)
I’ve place those missing files back inside /nbproject/ folder.
Now, if I try to switch to the Master branch, I’m getting this:
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’m aware that I should perhaps do a git add . to move those files on the repository, what I don’t understand is:
Why is git throwing this message IF I had nbproject/ ignored well before those git checkout commands being issued?
Question:
The point is to ignore those files. Both on master and dev. My question is: how can I fix this in order to:
a) First:
get those files (the ones on gitignore) back to dev ?
b) Second:
make steps to avoid this conflict again.
Steps taken to solve the problem.
Credits go to: jszakmeister
1) I have cloned the project to somewhere else.
2) I’ve checkout master on that clone.
3) Placed the gitignore into the master as it should have been there from the beginning:
git show dev:.gitignore > .gitignore
4) I’ve removed the files from the tree by doing git rm “all files that where on gitignore one by one”
5) I’ve added the .gitignore file to the repo.
6) commit it
7) switch back to the original repo and did:
8) git fetch /path/to/fix-project master:master
9) git checkout master, and I got:
Switched to branch ‘master’
Your branch is ahead of ‘hub/master’ by 1 commit.
this is my remote master branch.
10) Pushed to remote master.
11) checkout dev again