I have 2 branches in my Java project: master and refactor. I've finished working on refactor so now would like to checkout master
and merge refactor into master. While working on the refactor, I also added some files to .gitignore (one of them was .idea) and now I get:
[michal@michal-pc MCleaner]$ git checkout master
error: The following untracked working tree files would be overwritten by checkout:
.idea/description.html
.idea/misc.xml
.idea/modules.xml
.idea/project-template.xml
.idea/vcs.xml
Please move or remove them before you switch branches.
Aborting
I've read many posts and nothing works. How can I remove those files without accessing master branch? Is there a way to fix that? Please provide cmd commands if you can, I'm still new to git.
Here is the output from git status
:
On branch refactor
Your branch is up-to-date with 'origin/refactor'.
Untracked files: (use "git add <file>..." to include in what will be committed)
.idea/
target/
nothing added to commit but untracked files present (use "git add" to track)
Add the following to .gitignore
.idea
and remove this directory
git rm -r .idea
Then commit changes.
First run
get checkout <branch_name>
The result will be something like the following
error: The following untracked working tree files would be overwritten by checkout:
.idea/codeStyles/Project.xml
.idea/codeStyles/codeStyleConfig.xml
.idea/workspace.xml
Please move or remove them before you switch branches.
Aborting
If you're ok to lose any data in those files (THEY WILL BE OVERWRITTEN) go ahead and run
get checkout <branch_name> --force
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With