.gitignore and "The following untracked working tree files would be overwritten by checkout"
WARNING: it will delete untracked files, so it's not a great answer to the question being posed.
I hit this message as well. In my case, I didn't want to keep the files, so this worked for me:
git 2.11 and newer
git clean -d -f .
older git
git clean -d -f ""
If you also want to remove files ignored by git, then execute the following command.
BE WARNED!!! THIS MOST PROBABLY DESTROYS YOUR PROJECT, USE ONLY IF YOU KNOW 100% WHAT YOU ARE DOING
git 2.11 and newer
git clean -d -fx .
older git
git clean -d -fx ""
http://www.kernel.org/pub/software/scm/git/docs/git-clean.html
-x
means ignored files are also removed as well as files unknown to git.-d
means remove untracked directories in addition to untracked files.-f
is required to force it to run.
Warning: This will delete the local files that are not indexed
Just force it : git checkout -f another-branch
It seems like you want the files ignored but they have already been commited. .gitignore has no effect on files that are already in the repo so they need to be removed with git rm --cached
. The --cached
will prevent it from having any effect on your working copy and it will just mark as removed the next time you commit. After the files are removed from the repo then the .gitignore will prevent them from being added again.
But you have another problem with your .gitignore, you are excessively using wildcards and its causing it to match less than you expect it to. Instead lets change the .gitignore and try this.
.bundle
.DS_Store
db/*.sqlite3
log/*.log
tmp/
public/system/images/
public/system/avatars/