My branch “branch_a” has a file (file_a.txt) which should NOT be different from the like-named file on “master”. I’d like to alter the branch in such a way that this changed file is removed from the branch, that is, so that the unchanged file from “master” is again present, NOT a changed branch of that file. What I’m trying to avoid is having to maintain this file, which should never have been changed.
I thought at first git-reset might be helpful. Then I thought perhaps I should “git-rm” the file, but that will not leave me with the file at all. I need to remove it from the branch, so that it is no longer a different version that that on “master”. What is the best practice in this situation?
I assume you just need to reset that file back to the version on
master, not erase any history of changes, correct? The former is easy, the latter requires history modification and should not be done lightly (especially if you’ve pushed the branch outside of your local repo).To reset the contents of file
foo/bar/baz.txtback to the state it has onmaster, just check out your branch and runThis will grab the file from master, write it into your working copy, and stage it in the index. You can now just
git committhat and your file will now match the one onmaster.