In svn, sometimes I delete a local file then use 'svn update' to get a clean copy. How can I do it in git? git pull/fetch didn't work. The only way I figured out is use diff which is incontinent. Thanks. I'm using tortoiseGit.
Files are staged and committed differently in git and svn. The gist of the difference from git’s perspective is that with git a file is versioned through a staging area called an index, from there it goes as part of a commit to the local graph of commits that your branch points to, and from there it is propagated to the remote graph of commits when you push the branch to the remote server.
While acknowledging that “latest” is somewhat misleading, to simplify a bit, there are four “latest” file versions: the one in the working tree, the one in the index, the one in the local branch and the one in the remote branch. And the local and the remote branch are not necessarily in sync. So when you say that you want a clean copy of a file you have to refine the question first - and answer to yourself which of the four you are after.
$ git checkout -- /path/to/file
$ git checkout HEAD -- /path/to/file
$ git checkout origin/master -- /path/to/file
$ git fetch
$ git checkout origin/master -- /path/to/file
$ git pull
$ git checkout master -- /path/to/file