The Patr-onus Deployment Blog

How tos & best practices used in the deployment & maintenance of live websites & webapps.

Getting started with Git

Reshwin Nishith E
The Patr-onus Deployment Blog
4 min readOct 18, 2021

--

To start off, let’s get one thing cleared: Git isn’t the same thing as Github. Git is a version control system (I.e., software) that helps you keep track of your computer programs and files and the changes that are made to them over time. It also allows you to collaborate with your peers on a program, Code, or file. GitHub is a website that Hosts a Git server program to hold your code.

Step 1: Create a GitHub account

First thing’s first, you’ll need an account on GitHub: Head over to GitHub.com to create your free GitHub account. Pick a username, enter your Email address and a password, and click sign up for GitHub.

Step 2: Create a new repository

A repository is like a place or a container where something is sorted. Here, we’re creating a Git repository to store code. To create a New repository, Select New repository from the + sign drop-down menu. Enter a name for your repository and click create repository.

Your first repo is up on github.com

Step 3: Create a file

Open the terminal program on your computer.

Type Git and hit enter. If it says command bash: Git: command not found, then Install Git with the command for your Linux operating system or distribution. Check the installation by typing Git and hitting Enter.; if it’s installed, you should see information about how you can use the command.

Note: let’s call our repository ‘demo’ for this example

In the terminal, type:

mkdir Demo

This command will create a directory (or folder) named Demo.

Change your terminal to the Demo Directory with the command:

cd Demo

Then enter

echo “#Demo” >> README.md

This creates a file named README.md and writes #demo in it. To check that the file was created successfully, enter:

cat README.md

This will show you what is inside the README.md.

Now, to tell your computer that Demo is a directory managed by the Git program, Enter:

git init

Then, to tell the git program you care about this file and want to track any changes from this point forward, enter:

git add README.md

Step 4: Make a commit

Now that you’ve created a file and told Git about it, It’s time to create a Commit. Commit is like a bookmark. When you get some work done, you can write a Git commit to store that version of your file, so you can go back later and see what it looked like at that point in time. Whenever you make a change to your file, you create a new version of the file different from the previous one.

To make a commit, enter:

git commit -m "first commit"

Congrats! You’ve just created a Git commit and included a message that says First commit. Writing a message at commit ensures that you’ve got tags attached to your changes so when you come back later, you’d still know what the Changes were to each commit. If you go through your Git log, you will get a list of all the changes in the file.

Step 5: Connect your GitHub repo with your computer

Now, it’s time to connect your computer to GitHub with the command

git remote add origin https//github.com/<your_Username>/demo.git

Let’s break down this command and see what exactly is happening. We are telling Git to add a remote called origin (you can name it anything you want, we’re calling it origin for this example) with the address Https://github.com/<your_username>/Demo.git. This allows you to interact with your git repository on GitHub.com by typing origin instead of the full URL and Git will know where to send your code.

Now we have connected our local copy of the Demo repository to its remote counterpart on GitHub.com. Now that we have added the remote, We can push our code to GitHub.com:

git push -u origin master

That's about it! You have created your first GitHub repo, Connected it to your computer, and pushed (uploaded) a file from your computer to your repository called Demo on GitHub.com.

Some terms you’ll come across

  • Repository (repo) — a folder in which all files and their version histories are stored.
  • Branch — a workspace in which you can make changes that won’t affect the live site.
  • Markdown (.md) — a way to write in Github that converts plain text to GitHub code. Sites such as Atom and Sublime Text are examples of free resources for developers using Markdown.
  • Commit Changes — a saved record of a change made to a file within the repo.
  • Pull Request (PR) — the way to ask for changes made to a branch to be merged into another branch that also allows for multiple users to see, discuss and review work being done.
  • Merge — after a pull request is approved, the commit will be pulled in (or merged) from one branch to another and then, deployed on the live site
  • Issues — how work is tracked when using git. Issues allow users to report new tasks and content fixes, as well as allows users to track progress on a project board from beginning to end of a specific project.
  • Federalist — a platform that securely deploys a website from a GitHub repository in minutes and lets users preview proposed and published changes.

For more content on getting started with deployments & everything devops, check out the Patr-onus blog.

--

--

The Patr-onus Deployment Blog
The Patr-onus Deployment Blog

Published in The Patr-onus Deployment Blog

How tos & best practices used in the deployment & maintenance of live websites & webapps.

No responses yet