Intro to Git & Github for beginners(Tutorial)
Tags: Github, Beginners Guide, Programming, Git

I know its been hell trying to manage apps as a beginner but when you are done reading this article, you would feel like you are on top of the world because your previous predicament will be over.

Also , there would be a bonus tip for you at the end of this article so stay tuned guys!

What is Git and Github?

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

GitHub is a Git repository hosting service, but it adds many of its own features.

Basically, Git is a version control system for tracking files.

Git helps you to store your code in an amazing time machine and storage facility called Github.

Well enough with the long talk .

I know you guys want the meat and potatoes of this write up so I won't take more of your time.

So let's get this party started!!

By the way guys, I am Agbejule Kehinde Favour.

Downloading Git

So first let's download git

To download on windows , use the link below

http://git-scm.com/download/win

To download on mac, use the link below

git download page

* Keep clicking the next button until you reach this configuration phase on windows

*Choose the 3rd option for this configuration phase

*Finally click install

Now we are done with the download process

Creating a Github account

You need to create a git hub account.

So here are the steps:

*Go to Github.com

*Click on sign up

*Enter all the required details

*Then click sign up.

Now you have created your Github account.

We are going to be pushing the code of an existing coding project on your computer to git hub.

Initializing the git repository

# Right click on the folder.

# click on git bash.

#Then a git command line pops up.

Type ;

git init

and press enter

If there are no errors, it has initialized your local git repository

Config method

So before we start the process, we have to add our names and email addresses to git.

We use the git config method for that.

For name

git config --global user.name ' your name'

For email

git config --global user.email ' your email address'

Checking the status of your repository

git status

This code checks whether you have a file in your repo or not.

Any file written in red has not been added to your local repo.

And any file in green has been added to your local repo.

Adding files to your repo

To add a single file to your repo, type this;

Git add name of file

For example;

git add test.js

Adding files in the same category

HTML files

git add *.html

JavaScript files

git add *.js

If you want to add all files in the folder or app into your repo, type this;

git add .

Committing files

To commit your files into your local repo, type this;

git commit -m 'comment'

This code is basically for committing all files that has not been committed .

‘comment’ can be any comment you want to place as a description of why you committed that file.

For example;

If you commit a CSS file, your comments in the quote should be something like 'added frontend' or 'added frontend functionality'.

This gives a description of why you committed the file

git commit -m 'added frontend functionality'

.gitignore and readme files

.gitignore files are used when you want to commit all files to your repo excluding some unnecessary file.

E.g log.txt files

How to create and work with a .gitignore file

*Create a file named '.gitignore' in your folder.

Inside that folder, write the name of the file you want don’t want to include

log.txt

*Excluding a whole directory

In the .gitignore file, type;

/ hello

hello is the name of the directory

To confirm if this worked;

add your files using your git bash

Then check your git status

You would only see .gitignore as an added file and you won't see the excluded file or directory.

Readme.MD

A readme file is basically file you give a description about your project or app

MD is the short form of Mark Down

Creating your readme file

*Create a file called readme.MD in your folder

You actually write in this file with a kind of syntax ( mark down syntax)

Don't panic!

Its pretty easy.

This is actually just like writing any other file but it has its own syntax

Pushing your files from the local repo into your remote repository

Since you already have an account on github, follow these steps:

*Go to github.com

*Sign into or log into your account on github.

Once you are in, go to the top right corner of the page and click on the plus sign icon.

A dropdown would appear.

*Click on create new repository.

Then you would see the page below.

*Type your repository name

*You can give a description if you want to since it is optional

*Then you have public or private

Public; anyone can see it

Private; you can choose who see it and commits

*Then press create repository.

Now let's go to our git bash

Type:

git remote

and press enter.

This code would list all your remote repositories if you have.

But right now we have none.

Then on your github page you will have this.

*Git remote add origin 'URL link'

git remote add origin 'URL link'

*Copy and paste the url link in the code above in your git bash.

So now if you type:

git remote

It would return

Origin

Push our code into our remote repo

Type this code :

git push -u origin master

Then it pops out a dialog box where you have to log into github for validation purposes.

If it doesn’t show any errors, it means your code has been successfully pushed.

You can also refresh your github page.

If your code pops out it has been successful.

It would show 1 commit because this is your first time to push code into that repo.

The number of commits would continue to increase when you keep committing and pushing code into that repo.

In conclusion, git init= initializing local git repo git add <file> or git add . = add file or files to index git status = check the status of your repo git commit commit changes in your repo git push push to remote repo

Thank you guys for your time!

SMASH the clap button if this has brought a lot of value to you and if

you enjoyed this content.

It would help the blog grow and it also keeps me going.

If you are finding value, there is a high chance one other person is finding value too, so if you hit that clap button, it makes sure to go to that person and that would be amazing.

Please make sure to follow me to get more of these value packed contents.

BONUS TIP:

If you want to improve your git & github skills

JUMP RIGHT IN HERE, and you wont regret it

Thank you guys for your time and as always i would see you in the next article!

Until next time guys !

Agbejule Kehinde Favour .