Git - Need a Simple Tutorial

As a relatively new web developer, I think I have spent more time learning about tools and how to use them than I have coding. That might be an overstatement, but I do find myself spending tons of hours doing things to ensure the integrity of my work environment and processes.

Based on a misspent youth as a COBOL/BAL programmer, I knew I needed a version control and repository system which quickly took me to Git. I’ve learned the bare minimums. I learned that there is a .git directory and that I can manage a .gitignore file. I can check status, do adds and commits and push to a GitHub repo. I have not yet found a need for branching.
I think it’s time for me to learn more, but most of the tutorials I’ve been through advance too quickly and cover ground that has no application for me. So, I’m seeking advice on free tutorials that I can investigate to improve my understanding of the git process and specifically to make better use of tools. So far, I’m done every thing in the command window; therefore, if there are tools and UIs you might suggest I look into, please list them, too.

1 Like

Many IDEs, such as Visual Studio, Visual Studio Code and Eclipse, provide interfaces to Git.

There is also the GitHub Desktop.

1 Like

Branches are the most useful feature of VCS.

you should have at minimum two branches

Develop

Release

so you do all you development in the development branch which reflects more or less your local version of the web app.

When you finished a new feature, you merge it into the release branch, which is a copy of what you have on your web server (host).

Normally you have something like a

Stage

branch in between. This is the copy of the test version on the web server.

So the standard workflow is:

Do your changes in Develop and test locally. Merge them into Stage, test them on the server and then merge Stage into Relase to deploy to production.

When you use GitHub you can add an action runner to your repos. This is then able to move all the files to your server. This means, when you push a stage or release version to GitHub, this versions are automatically deployed on the web server. Little bit tricky to install and configure this but super cool when it works as it saves you so much time and also reduces deployment errors you often have when you do it manually like forgetting a changed file, forget to set correct file owners or access rights etc.

when you find a bug in your release, you just create a new branch

Bugfix

from the release branch, fix the error, merge the Bugfix branch back into the release branch and deploy it. Then you also merge the Bugfix branch into your Develop branch to have the bug fixed in your actual working code also.

this all saves so much time and nerves I will never ever miss it

3 Likes

Make sure your environment variable file is in the .gitignore.

People are commiting their environment variable files to Github where all those API keys use for AI use are.

I don’t know how true is this, but is quite pausible.

Student hit with a $55,444.78 Google Cloud bill after Gemini API key leaked on GitHub

You should never ever have your credentials file be part of the project!

Put it somewhere completly different. Also on the server it should never be in a folder which is accessible by the Webserver.

I can second that. The number of hits we get on our servers at work looking for .env files is insane. If you put it there it’s not a matter if someone will find it, it’s a matter of when they will find it.

BTW it’s easy to make it harder for the hackers. My credential files are never named .env :slight_smile:

Best to place them outside of publicly accessible folders anyway, regardless of what you call them.

And I don’t mean a folder with an .htaccess file that forbids access, I mean at least one folder up from the public root.

YouTube has a lot of tuts on Git.

.env file is not accessible by webservers (unless you misconfigure it). That is like saying your app source code is accessible by webserververs. In fact sometimes webservers run in what is called demilitarize zones, and the webapp run behind firewalls.

.env are loaded by the app, requests are not able to get to it.

Yes, if you want extract protection of not sending the .env file by mistake to github, then yes put it outside the project.

Not sure what we are talking about but Apache does not take care about what extension a file has. Maybe some crazy windows server stuff is doing this be default but I don’t think your message is true in general.

Basically, you put your website in /home/someuser/somewebsite.com/public, tell Apache to serve from there (use it as DocumentRoot) and then put your .env file in /home/someuser/somewebsite.com/.env. So there is absolutely no way to get that file from Apache as it won’t serve files outside the document root.

Same applies to other servers like NGiNX, IIS, etc.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.