The context is, I’ve added some changes to a file using add -p and because of the way git was presenting the patches I can’t be sure the result will be good. I want to see the file as if I’d committed, then pushed, and then someone else had pulled the file. Not the diff, I just want to see that final version of the file. I need to preserve my changes to the current file, any clobbering of that file would be vexing to say the least!
The only way I can think to do this is:
- Commit the changes.
- Stash the rest.
- If anything is amiss then either rollback the commit, or add in more commits and squash it.
The main problem I have with a rollback is that I’ll have to go through all the adding again. Squashing could be problematic too – it would just be easier if I could see the staged file in one piece before commit. Is this possible, or is there another “easy” way? (nothing arcane please, Git is already too arcane for me to get knee deep in just for this!)
You can use
git cat-file.Note that the path is relative to the top of the repository.