|
Programming

Git and GitHub for people who are scared of the terminal

You only need five commands for your first month. The terminal is not a test of your intelligence, and a merge conflict will not kill you.

Git and GitHub for people who are scared of the terminal

A student once sent me a folder called final project final final real one. Inside were six other folders, each a slightly different version of the same app. She had been saving copies because she was afraid of Git. She had heard about merge conflicts and decided the terminal was for people smarter than her.

I understand the fear. The first time I opened Git Bash, the black screen with the blinking cursor felt like a room where mistakes are permanent. They are not. Almost everything in Git can be undone, and the commands you need at the start fit on a sticky note.

Git is not GitHub

Git is the tool on your laptop that records changes. GitHub is a website that stores a copy of those changes online. You can use Git for years without GitHub. You cannot use GitHub properly without Git.

Think of Git as a notebook of every version of your project, and GitHub as a safe place to keep the notebook so your laptop can catch fire and you lose nothing. That is the whole relationship. Everything else is detail you can learn later.

Install once and set your name

On Windows, install Git for Windows. It comes with Git Bash, which gives you a terminal that understands the commands in every tutorial. On a Mac, open Terminal and type git --version. If you see a number, it is already there.

Then tell Git who you are. Run these two lines once, with your own details:

git config --global user.name "Your Name"

git config --global user.email "you@example.com"

If you skip this, your commits will have no author and GitHub will not count them on your profile. It is a small thing that makes your work look unfinished.

The five commands for your first month

That is not an exaggeration. These five cover most of what a beginner does:

  1. git init turns a folder into a Git repository. Run it once per project.
  2. git status shows what changed. Run it constantly. It is the command that stops panic.
  3. git add . stages your changes for the next commit.
  4. git commit -m "message" saves a snapshot with a note about what changed.
  5. git push sends your commits to GitHub.

There are more commands, but you do not need them yet. Learn these until they are boring. Boring is the goal.

Your first repository in ten minutes

Create a folder for a small project. Open Git Bash inside it, or right click and choose Git Bash Here. Run git init. Create a file called README.md with one line in it. Run git status and you will see the file listed in red as untracked.

Run git add . and then git status again. The file is now green. That is staging. Run git commit -m "first commit". Now the file is recorded in the project's history.

Go to GitHub, create an empty repository, and copy the two lines it gives you for an existing repository. One adds the remote, one pushes. Refresh the page and your file is there. That is the entire beginner workflow, and it takes less time than reading this section.

Branches, pull requests, and why jobs care

A branch is a copy of the project where you can work without touching the main version. You create one, make changes, and later merge it back. Companies use branches so ten people can work on the same code without stepping on each other.

On GitHub, a pull request is a request to merge your branch into main. It shows the difference, lets people comment line by line, and keeps a record of why the change happened. Junior job interviews often ask if you have opened one. If all your work is on main with messages like "update", the answer is technically no.

Practice this week: create a branch called test-branch, change the README, push the branch, and open a pull request against your own repo. Merge it yourself. Now you have done the thing the job description mentions.

A merge conflict is just a question

A conflict happens when two branches change the same line and Git cannot decide which one wins. It stops and asks you. That is all. It is not corruption and it does not mean you broke the project.

Open the file. You will see markers like <<<<<<< HEAD, then your version, then =======, then the other version, then >>>>>>>. Delete the markers, keep the text you want, save, then git add the file and commit. The conflict is resolved.

The first time feels like defusing a bomb. The third time feels like editing a document. I have resolved hundreds and the only real skill is reading carefully before deleting.

Two mistakes I made early

I committed my .env file to a public repo in 2020. It had a database password and an API key. A stranger forked the repo within a day. Nothing terrible happened because the key was for a free service, but I learned the lesson cheaply. Now every project gets a .gitignore before the first commit, with .env and node_modules in it.

I also used to write commit messages like "fix" and "update". Six months later I could not tell what changed. Write what you did: "add phone validation to contact form". Your future self is the main reader.

What to do this week

Install Git, set your name and email, and put one existing project on GitHub. Not a new project, an existing one. Then make one change, commit it, and push it. The fear dies the moment you see your own code on the internet with a green commit square.

If you are still choosing what to build, read how to build your first CRUD app. When something breaks and you do not know why, how to debug code without panicking will help. The Software development for absolute beginners course includes the setup walkthrough if you want company while you do it.

Dave Partner

Dave teaches digital skills at Braintem and has helped thousands of Nigerians move from watching tutorials to charging for real work. He writes about the parts nobody puts in the course trailer.