-1

I noticed that SVN revert doesn't EXACTLY behave the same way as GIT checkout...:

SVN case: If I have a SVN remote repository that I checkout on my computer, and make modifications on a file locally. While I do this, someone commits new changes on that same file on the server.

Now I want to revert my changes on my local repository. I do

svn revert [file]

And this gives me the file in the exact same state as the one I had on my computer when I checked out the remot repository.

GIT case: Now With GIT. I clone a remote repository, do some changes on a file, someone pushes some commits that affects that same file, and I want to do

git checkout -- file

This is gonna give me the version of the file modified by that someone mentioned earlier, not the file I cloned at the beginning of this user story.

Now, I guess I could do:

git checkout [commit number of the remote version I cloned] -- file

But I find it "tedious / vexing", knowing that I just want to revert my file to the local version of my repository.

So my question is: Is there a way to specifically checkout a file to the version I had on my local repository when I last pulled the remote repository? something like:

git checkout local -- file

? Thanks in advance for your precious comments & answers =)

Zoe
  • 27,060
  • 21
  • 118
  • 148
lagarkane
  • 915
  • 2
  • 9
  • 22
  • 3
    Have you tried to do `git checkout -- file` before writing the question? Because it will checkout appropriate version of file, unless you did `git pull` before, which you didn't because you needed to resolve conflict in `file` in this case. – Paul Dec 02 '14 at 12:05

1 Answers1

0

If I understand what you're asking correctly, what you need to remember is that git is configured (usually) for the "master" branch to track the remote/upstream master.

What you probably want to do is create a local branch right after you clone the repository: git checkout -b my_branch — and do your work here, so its unaffected by changes upstream, but these changes will still be pulled into your local master branch.

You can then git rebase your changes onto the current master, when you're ready, at your convenience.

Geoff Nixon
  • 4,697
  • 2
  • 28
  • 34