We're having some issues with our developers potentially losing their local code, especially before they manage to push their work to staging. With so many feature branches being worked on, I think it's getting a bit chaotic. Just the other day, one of the devs accidentally deleted all his local files after running a 'git stash pop'. We've talked about his workflow and suggested he should 'git stash apply' first before cleaning up, but accidents happen. I'm looking for best practices to ensure our developers have backup options and a smoother workflow. Here are some thoughts I've had:
1) I know about using 'git bundle', but I'm not quite sure how to implement it.
2) Perhaps we could set up a backup repository specifically for development, without exposing the entire application code to prevent any sensitive information from leaking.
3) Should we just move non-CI branches to the standard repository?
6 Answers
We have a rule to limit active branches to three per developer. This encourages everyone to commit often and break their work into smaller pieces, reducing the risk of losing several days of progress. Also, I think the team could benefit from somewhat standardizing committing practices, but personally, I find that slows me down. I prefer to commit anything anytime and squash before merging!
Ultimately, you need a solid centralized repository for version control. If branches are getting cluttered, consider improving your branch naming system. If the team is super busy, you might want to enable everyone to have their own remote setup and just handle PRs into the main repository.
There's nothing wrong with pushing to feature branches! You can easily set it up to delete branches after merging. It helps to maintain organization and makes sure everyone's changes are backed up regularly.
Remember, Git itself is your backup! You should be pushing to Git regularly. I'd recommend running CI checks on every push rather than avoiding CI with non-CI branches. This way, there's less chance of losing valuable work.
If you're open to trying something new, GitButler has been a lifesaver. It creates restore points from local changes without needing to commit or push to a remote. It has its quirks, but I find it worth it for the easy one-click restore if something goes wrong.
Having lots of branches isn't really a bad thing; it's part of the local dev process! Each developer should really push their feature branches daily. It keeps their work backed up without complicating things. Plus, once they're ready, it's just a matter of opening a PR to merge into the main branch.
Related Questions
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically
[Centos] Delete All Files And Folders That Contain a String