Stophface Stophface - 3 months ago 16
Git Question

git pull error when working with remote repository

I set up this project completely new.
I created a

remote repository
and did this on my local machine.

$ git init
$ git remote add origin git@...
$ git add .
$ git commit
$ git push -u origin master
$ git branch -u origin/master

Then I wrote something into the readme in the
remote repository
. When I type on my local machine
git checkout master
I get this:

Already on 'master'
Your branch is behind 'origin/master' by 2 commits, and can be fast forwarded.
(use "git pull" to update your local branch)

However, when I try to do
$ git pull
as suggested I get this:

error: The following untracked working tree files would be overwritten by merge:
Please move or remove them before you can merge.

How do I get the changes from
to my


Like Git says, you have to remove your untracked working tree files (in your case there is only one called ''). If you have changes you want to keep, commit them, and then do a pull.

Question: why didn't you do a git clone ...?


When you do a git pull, git does a git fetch followed by a git merge. The merge could be as simple as a fast-forward, if you did not divert from the remote. But if you did, git needs to merge the changes together. To make sure you do not loose any work, git complains if there are changes to a file that will be touched by a merge in your working directory.

To keep your changes you can either

  1. add the file to your index (git add, create a stash (git stash), do a merge (git merge origin/master) and pop you stash (git stash pop) or
  2. create a commit given your changes (git add followed by git commit) and then merge in the changes from the remote (git merge origin/master)