Introduce Git Into Your Every Day Routine Is Critical, Even For Freelance Developers Enter a brief summary for this post

Introduce GIT into your daily routine

Rather interestingly how many web developers use GIT in their everyday routine? I will share my experience with GIT as I've found that I can feel more secure because of it.

The futility of manual backups

If you are not using GIT to make your work safe then I guess the best alternative is to back up the files to another drive. This is how many freelance developers would likely manage securing their critical data. And how I managed myself but I eventually grew weary and tiresome of the daily chores.

The amount of disk space required to back up grows weekly and becomes unmanageable. When faced with this then it is time for you to install GIT on the command line and set up a GitHub account (it's free).

Talking to many freelance PHP developers the overall consensus drew on GIT being designed for teams and not the independent lone developer. As I found out that's far from the truth. There are many benefits from GIT for freelancers.

Benefits from GIT

Ease of use becomes apparent straight away. Simplicity too is another benefit. Once you have cleared the hurdle of learning the basics you can enjoy GIT from that point onwards. There are other benefits such as:

  • a push and pull affects only what has changed since the last commit
  • a change happens in a silo with no impact on other changes going on elsewhere
  • you can reverse changes with no limit

You quickly develop a routine and workflow even if it's only yourself as an independent developer. For many freelance projects you can push and pull on the "main" branch. That will suffice but for larger projects you will find the need for a second branch to work with in front of "main".

Within a team environment you will definitely not be working on the "main" branch. In fact, chances are you won't even have access to it.

The second branch is typically called "developer" and you push to this daily and the "main" weekly (I do at least).

The GIT workflow

However, working on the "developer" branch is a risk to the ease and security I originally sought. Before I begin any new developments or adaptions, I create a "features" branch to work with. This allows me to work on any number of new developments as each one is its own branch.

I recommend you do the same, naming your feature branches like so: "feature-pr01", "feature-pr02",... "feature-pr39" and so on.

Why like so? It is because when you push a feature branch to your GIT repository it will create a "pull request" so the naming convention refers to that particular pull request.

Before you head over to your GitHub repository I would check out into the "developer" branch first on your local repository, as a precaution.

On the GitHub repository in question, you will see the pull request. If you are just yourself you can merge the request into the "developer" branch. Don't make the mistake of merging into the "main" branch which is selected by default.

When the merge has been done you go back to your local repository command line and pull down the "developer" branch to update your local. The earlier precaution explains why you checkout first into the "developer" branch - on occasion I have pulled the remote "developer" branch down into the feature branch in error.

So, checkout to the "developer" before going to GitHub.

If you are working within a team environment the chances are someone else will manage all the pull requests. So, you just pull down the "developer" branch each time you've pushed to it. When the person who does merge the pull requests your local repository will update as and when on each pull of the "developer" branch.

Taking GIT further

This is basically how you could use GIT to better manage the security and accessibility of your freelance projects. But there is more.

I must say I had little knowledge of what CI/DI (continuous integration and deployment) was about before GIT. You will discover GIT is also a tool for pushing a repository to a live server. This can work for you manually or it can be automated through what are known as "Git Actions".

It is often the case with freelance projects you use FTP a lot but experience states that it isn't always reliable. How many times have you cursed at broken connections? Well, "Git Actions" are reliable and I'm positive you will want to look at CI/DI too.

Conclusion

In various discussion groups there is talk of the fear of "losing data" through mistakes. That is nonsense. What can happen is you can contaminate one branch with another if you're not careful. Those mistakes can be undone though so there is little to worry about.

Not enough for you not to use GIT.