I have a Git repo locally and its files are uploaded on a server over FTP. I don't want to upload files one by one, so I'm trying to set up Git on the server as well. This would allow me to simply SSH and git pull
the files from GitHub instead.
Since I already have the latest version of the files on the server, I want to initialize the repository at the latest commit and Git should be doing nothing with the files because they're the same. However, that's not the case:
ssh myserver
cd /path/to/project
git init
git remote add origin https://github.com/user/repo
git fetch
git checkout master
The last command outputs:
error: The following untracked working tree files would be overwritten by checkout:
...
Please move or remove them before you switch branches.
Aborting
Why does that happen? The files that Git wants to overwrite and their contents are exactly the same. Shouldn't the checkout happen without problems?