While checkout to master branch, I got:
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.xmlPlease move or remove them before you can switch branches. Aborting
So I have remove them (I’ve backup those files somewhere else outside the repo), and I was able to switch again.
The reason I’ve getting this it’s because:
dev is ignoring those files.
master isn’t, because no .gitignore file is present there.
They should both ignore those files.
Plus, when I push this to remote repos, those changes should be propagated for those remote repos as well.
How can we add that .gitignore file to the master, so that this doesn’t happen again ?
Adding a
.gitignorefile is the same as adding any other file. Create it, and what you want to ignore to it, and then add it and commit it. You can ignore those files specifically with:You’ll likely need to do the same on all your affected branches.
BUT, you do have something else going on. The fact that git is telling you those files are in the way, isn’t because they’re ignored on your master branch… it’s because they’ve been committed to your master branch. IOW, they are now under version control. I think you need to not only ignore them, but possibly remove them from version control too. That’ll be something you may want to coordinate with your team, so that anyone on master knows the files will be disappearing, and they can back them up beforehand.
UPDATE: MEM and I chatted about this. We ended up fixing his repository by making another clone, checking out master, adding the .gitignore from his dev branch (via
git show dev:.gitignore > .gitignore), and then fetching that revision back into his original project (viagit fetch /path/to/fix master:master). Once he had the new revision, we pushed it to the remote, so everyone else would have it too.