Git and removing files…

Most of the time that I have spent in Xcode working on a project under source control (Git) has been my own project or something very simple with perhaps one other person not spending much time committing and pushing code. That’s just the way things have gone for ages.

I recently started working within a project that is really quite large with the hands of many developers involved. Submodules, merge conflicts, terminal use instead of using a GUI. etc. Source control is some of the scariest shit in the world – especially when something busts and you don’t comfortable screwing around trying to get things working again. I know Git is supposed to make all that more worry free, but when you can’t build a project for numerous reasons that involve source control, it’s quite stress inducing.

Something that is very easy was something I could not find a definitive answer about. Perhaps because it’s so dumb and easy not documentation has been deemed necessary. The situation was I had a feature branch and for a pull request I had to refactor some code and I ended up wanting to remove a class file from the project. I sweated this for a bit. Because messing something up sucks, and I feared getting an error after my attempt and messing things up.

So I right-clicked on the file in question that I no longer needed, selected Delete – and was asked if I wanted to remove the reference or move it to the trash. Keeping it on disk I felt more dangerous and decided to move it to the trash. Done. Now when I went to Sourcetree to commit, I saw the file listed with a flag that it had been removed. Oh, that’s good! I committed and then pushed. I checked the repository and looked at my branch. It was gone, and a diff showed that difference.

Super fucking easy and it makes all the sense in the world. But that small operation failed to turn up anywhere online that I could find. I saw a note about using the Finder to remove the file and then commit it. Which is what I did, only from Xcode and not the Finder – but it ended up doing the same thing. Lookin back its the most simple thing in the world, but if you haven’t done that before under source control, its a little daunting. I’ve been in a position where tooling caused a project to break and I tried all sorts of searching and trial and error – and dumping a local repo and performing a fresh clone got me around the problem. When you commit and then push without any errors is like taking a shot of whisky.

🥃 Wonderful.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.