1

I have this bad habbit where if I see unformatted code, I format it.

This is bad because the benefit of the change is not directly related to the user story (akak ticket) I'm working on.

So I am currently on this branch:

feature/add-ability-to-manage-notes

I have made many changes and made many commits. On of these files had no relevant change other than my OCD with regards to the formatting.

The changes and commits are all local to my machine and have not been pushed to remote origin

I want to undo that one file to make it match the develop branch, so that when I create my PR, it doesn't get listed among the changed things. This way, it will be easier for my colleagues when they review my PR in GitLab.

How do achive this in using Git command line?

J86
  • 14,345
  • 47
  • 130
  • 228
  • The duplicate link gives you a one-liner you may use, but your IDE itself, if it has a good Git plugin, might have the ability to diff a file against any other branch/revision. You could do a diff of the file inside your IDE and revert it to its original state by hand, then add and commit that change before pushing. – Tim Biegeleisen Sep 20 '19 at 11:00
  • That duplicate link deals with reverting a particular file to some specific hash, how do I first find out what the hash is for that file on the `develop` branch? – J86 Sep 20 '19 at 11:01
  • 1
    `git checkout develop -- path/to/your/file.txt` – Tim Biegeleisen Sep 20 '19 at 11:02

0 Answers0