• Register
0 votes
273 views

Problem :

I added the folder to the .gitignore file.

Once I do the git status it tells me

# On branch latest
nothing to commit (working directory clean)

But when I try to change my branches I get the below:

My-MacBook-Pro:webapp marcamillion$ git checkout develop
error: The following untracked working tree files would be overwritten by checkout:
    public/system/images/9/thumb/red-stripe.jpg
    public/system/images/9/original/red-stripe.jpg
    public/system/images/8/thumb/red-stripe-red.jpg
.
.
Please move or remove them before you can switch branches.
Aborting

This is how the .gitignore file looks like:

.bundle
.DS_Store
db/*.sqlite3
log/*.log
tmp/**/*
public/system/images/*
public/system/avatars/*

How do I get this working for me so I can switch my branches without deleting those files?

7 5 2
3,870 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

It appears like you want your files ignored but they are already committed. The .gitignore has no effect on your files that are already in your repo so they must be removed with git rm --cached. A --cached will prevent it from having any effect on the working copy and it will just mark it as removed the next time you commit. After your files are removed from a repo then your .gitignore will prevent them from being added again.

But you have another problem also with your .gitignore, you must be excessively using wildcards and that is causing it to match less than the expect it to. Instead of that lets change your .gitignore and try as given below.

.bundle
.DS_Store
db/*.sqlite3
log/*.log
tmp/
public/system/images/
public/system/avatars/
9 7 4
38,600 points

Related questions

0 votes
1 answer 11 views
11 views
Problem: So I added a folder to my .gitignore file. Once I do a git status it tells me # On branch latest nothing to commit (working directory clean) However, this is what my .gitignore file looks like: .bundle .DS_Store db/*.sqlite3 log/*.log tmp/**/* public/ ... afterwards would everything be perfect as up to my latest commit? I don't want to lose those files, I just don't want them tracked.
asked Apr 30 muktaa 34.6k points
0 votes
1 answer 6 views
6 views
Problem: I added a folder to my .gitignore file. Once I do a git status it tells me # On branch latest nothing to commit (working directory clean) However, when I try to change branches I get the following: My-MacBook-Pro:webapp marcamillion$ git checkout develop error: The ... would everything be perfect as up to my latest commit? I don't want to lose those files, I just don't want them tracked.
asked Apr 26 sumaiya simi 43.9k points
0 votes
1 answer 12 views
12 views
Problem: Why I get this > Git the following untracked working tree files would be overwritten by checkout
asked Apr 28 ummeshani 10.8k points
0 votes
1 answer 19 views
19 views
Problem: HELP! I need help understanding this error > Git the following untracked working tree files would be overwritten by merge
asked Apr 30 ummeshani 10.8k points
0 votes
1 answer 29 views
29 views
Problem: Urgent problem, any help: Error: the following untracked working tree files would be overwritten by merge:
asked Mar 13 Wafa Abu Yousef 6.1k points
0 votes
1 answer 15 views
15 views
Problem: did anyone face this situation ! help : Error: the following untracked working tree files would be overwritten by merge.
asked Mar 6 Wafa Abu Yousef 6.1k points
0 votes
2 answers 3.5K views
3.5K views
Problem : On the branch I had some files in the .gitignore On the different branch those files are not. I am trying to merge the different branch into my branch, and I don't bother if those files are no longer overlooked or not. Unfortunately I get below ... by merge” How should I modify the pull command to overwrite those files, without needing to find, move or delete those files by myself?
asked Jan 6, 2020 alecxe 7.5k points
1 vote
2 answers 2.6K views
2.6K views
Problem : On the branch which I had some of my files in .gitignore On the different branch those files are not present. So I want to merge the different branch into my branch and I really do not care about those files if they are no longer ignored or not. But ... by merge How can I modify the pull command to overwrite the files, without me needing to find, move or delete the files by myself?
asked Dec 27, 2019 alecxe 7.5k points
0 votes
1 answer 5 views
5 views
Problem: anyone who know this problem please help? untracked working tree file would be overwritten by merge
asked Mar 30 Rohit kr 17.5k points