Reputation: 3014
Develop ------------------------>
\NewBranch---->
I keep accidently commiting files that should not be commited because they change during compile and we can't use ignore on them att the moment.
Is there a way with Visual Studios Team Explorer OR TortoiseGit to revert only a single file or several selected files back to the parent branch develop?
Upvotes: 6
Views: 5309
Reputation: 34003
In order to restore a file to a previous version you have several options in TortoiseGit, all start from the Log Dialog.
You select the revision where you accidently committed the files, go to the lower file list and open the context menu on the specific file(s). There you select "Revert to parent revision".
You select the revision you want to restore the files from and then select "Repository Browser" on the context menu of the revision. Now you see all files at this revision and you can save or drag'n'drop them to your working tree. (You can also directly open the Repository Browser using the context menu of the Windows Explorer, you might need to hold the shift key to see the entry).
PS: You could mark those files as skip worktree
to prevent them from committing.
Upvotes: 3
Reputation: 9065
git checkout Develop -- theFileYouWantToRevert
Moreover, if the file is generated and could be changed during compiling, you should consider add them to the .gitignore
file
Upvotes: 9