Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GIT: The following untracked working tree files would be overwritten by checkout

I have two branches one is called master the other is called dev I am currently in the master branch and I want to go to the dev branch to move a file to the development server. however when I perform a

$ git checkout dev

I get the message:

The following untracked working tree files would be overwritten by checkout:

pages/memclub/images/subheaders/leadership.png
pages/memclub/images/subheaders/male.png
pages/memclub/images/subheaders/marketing.png
pages/memclub/images/subheaders/training.png

I dont want to commit the files to the master, they are not ready to be pushed.

like image 258
Matthew Colley Avatar asked Sep 07 '12 17:09

Matthew Colley


People also ask

Does git checkout affect untracked files?

git checkout does not affect untracked files. Git only manages tracked files, and it works fairly hard to avoid letting you lose data (which is critical).

Is checkout overwritten?

The Git “Your local changes to the following files would be overwritten by checkout” error occurs when you make changes on two branches without committing or stashing those changes and try to navigate between the branches. You can fix this issue by either stashing your changes for later or adding them to a commit.


1 Answers

First you'll want to add the files in question so that they're tracked by Git (you don't have to commit any changes, but Git needs to know about the files):

git add pages/memclub/images/subheaders/leadership.png pages/memclub/images/subheaders/male.png 
git add pages/memclub/images/subheaders/marketing.png pages/memclub/images/subheaders/training.png

Then you can stash your changes:

git stash 

When you're ready to start working on the files again, you can use:

git stash pop
like image 100
Ethan Brown Avatar answered Oct 09 '22 03:10

Ethan Brown