Question: I’m using Git on Mac 10.9.5 and would like to pull down the latest version of what is in a branch. I don’t care about any local changes I’ve made — I’m happy to abandon all of those. Right now when I run

```
git pull origin branch-name

```

I get errors like

```
Please, commit your changes or stash them before you can merge.
error: The following untracked working tree files would be overwritten by merge:
    src/main/java/com/myco/classroom/dto/ClassroomCourseDto.java
    src/main/java/com/myco/clever/dto/CleverClassroomUserDto.java
    src/main/java/com/myco/clever/exception/MissingUserException.java

```

I don’t want to commit anything — I just want to get a fresh copy free of any local modifications I’ve done. How do I do this?

Answer: 
In case you did something wrong, you can replace local changes using the command

 `git checkout --` 

this replaces the changes in your working tree with the last content in HEAD.
Changes already added to the index, as well as new files, will be kept.

If you instead want to drop all your local changes and commits, fetch the latest history from the server and point your local master branch at it like this

`git fetch origin
git reset --hard origin/master`

Visit this site if you need more help with git: <http://rogerdudler.github.io/git-guide/>
[`git stash`](http://git-scm.com/docs/git-stash) is what you want to use.

> 
> Use git stash when you want to record the current state of the working directory and the index, but want to go back to a clean working directory. The command saves your local modifications away and reverts the working directory to match the HEAD commit.
> 
> 
> 

There's even an example similar to your situation:

> 
> Pulling into a dirty tree
> 
> 
> When you are in the middle of something, you learn that there are upstream changes that are possibly relevant to what you are doing. When your local changes do not conflict with the changes in the upstream, a simple git pull will let you move forward.
> 
> 
> However, there are cases in which your local changes do conflict with the upstream changes, and git pull refuses to overwrite your changes. In such a case, you can stash your changes away, perform a pull, and then unstash, like this:
> 
> 
> 

```
$ git pull
 ...
file foobar not up to date, cannot merge.
$ git stash
$ git pull
$ git stash pop

```