1

I use a Git server to control my code versions and updates. I've made a lot of changes to some files and did not commit anything. But I wanna clear all modifications made to a single file cause it didn't work as I expected. Example:

Files modificated:

Person.java
Document.java
Address.java
Phone.java

I want to "rollback" modifications made to:

Address.java

There is any way to do it without copying everything from HEAD revision to my current file?

I'm using Git Bash and Eclipse.

Thanks!

Deiwys
  • 243
  • 1
  • 5
  • 15
AndreDuarte
  • 784
  • 1
  • 5
  • 21
  • 1
    Since you aren't asking about any bash syntax, built-in commands, or functionality, arguably this is only a git question, not a bash question at all. Removing the tag. – Charles Duffy Sep 22 '14 at 20:07
  • possible duplicate of [Eclipse git checkout (aka, revert)](http://stackoverflow.com/questions/1750997/eclipse-git-checkout-aka-revert) – buff Sep 22 '14 at 20:14

1 Answers1

3

If I understood your situation right, you should be able to simply checkout the file in question:

git checkout -- Address.java

this will reset the changes only in that file. If you have already staged the file for commit (i.e. used git add) you should reset it first:

git reset Address.java
Tom Fenech
  • 72,334
  • 12
  • 107
  • 141
FatalError
  • 52,695
  • 14
  • 99
  • 116
  • That worked well. But for further information, Eclipse with Egit plugin does not provide a shortcut to do this, so it needed to be done by Git bash. – AndreDuarte Sep 22 '14 at 20:10
  • According to this response: http://stackoverflow.com/a/4104149/328977, Eclipse does provide a shortcut to this. – buff Sep 22 '14 at 20:14