I use the excellent GUI Git tool namely Git Fork, which I think does a remarkable job simplifying your Git workflow.
In my development job, lately, I notice that most of my local branches - have a tiny yellow warning sign - below the branch name and icon. This indicates that the remote branch has been deleted.
As a result, this scenario prompts me into thinking if we should keep all the branches we work on. By the nature of Git, apart from divergent branches, anything that is merged into the main branches should be present. Of course, while merging two branches with files having conflicts, work can still be lost.
For people managing the repository of a particular project and new developers on the project - when doing housekeeping stuff and/or creating merge requests - it's possible to be confused if there are hundreds of branch names. Therefore, it's a good practice to delete branches no longer required.
The relevant question - therefore is - do you still want to keep your local branches intact?
Recently, with an update, there is an issue with CORS on the project I am working on. With no solution in sight, I am tasked to revert to a previous version for the frontend part of the project. Docker and GitLab CI are used for the backend. We have containers of previous versions available. We just need to refer to which image version we want to backtrack.
For the front, I just reset to an earlier commit and push to the develop branch - which is directly connected to the staging environment. Doing all that does not solve the issue with CORS. Now it's time to revert back to the latest version. However, the original development branch no longer exists on the server and the develop one is at a previous commit.
In addition, my colleague no longer have the branch on his machine. Fortunately, I still have it on mine and kindly merge it into develop - without losing any work.
Having local branches in your machine can therefore be useful, particularly when you have tough deadlines. You simply need to use effective GUI tools such as Git Fork, Sublime Merge or SourceTree to manage your branches and resolving merge conflicts.