Gitlab

My Top 5 Reasons To Start Using CI/CD

For the first half of my career we moved code from our local machines -> dev -> test -> production the old cowboy way, just by copy & paste from one environment to the next. It’s quick and easy but also riddled with holes. Now we’ve got better ways of doing things with processes like CI/CD and source control systems like Gitlab and Github. Here are my top five reasons why you should have a CI/CD process or pipeline set up into your development workflow:

  1. Each commit can be traced to a specific environment allowing developers to see what code is in production or test at any given time.
  2. If you’re pasting files around, you can easily blow away or overwrite something you didn’t mean to.
  3. CI/CD pipelines let you can roll back commits and changes with the click of a button if you break something. Thus keeping you from scrambling to find that backup folder you created (or didn’t) before moving the code to production.
  4. Check in your code and forget. CI/CD pipelines will automatically move your changes to your environments for you.
  5. Pipelines will run unit and integration tests before deploying code. If the tests fail the migration is halted so breaking changes never make it to production.

This getting started guide for Gitlab is a good place to start with CI/CD.

Add A New Git Remote Repository

Working with different clients I often end up with multiple Git remote repositories. When I start a new project with a client I create the initial repository in my Gitlab called origin and if the time comes I will add another remote repository in the client environment with the name of the client clientABC. This is how to add a new Git remote repository in addition to your default Git repository.

Add the new remote repository using the git remote add command.
git remote add clientABC https://gitlab.com/clientABC/exampl-repo.git

Then when pushing or pulling from the different remote repositories make sure to include the appropriate remote name when running the commands. For example, when pulling from origin dev branch use git pull origin dev. And if you want to push your changes up to the new client remote use git push clientABC dev.