Basic Tutorial for Git/GitHub for Beginners Part-1

Esat Kemal Ekren
NSIstanbul
Published in
4 min readJan 19, 2019
https://git-scm.com/

Okay! Let’s get started. I was thinking for a while about the next story in here. I think this is a great topic for beginners.
Git is the version control system of your files that you can easily inspect all versions of your files. You can use this feature local or online. It’s totally up to you.
Here are the basic commands:
git init: This initialize a new git repository on our folder
git log: This shows the commits logs
git status: This shows the status of our files
git add: This command adds a new file in our repository
git commit -m: This command commits our files with message
git revert: It helps revert our commits previous ones
git reset: It resets commits that we want to delete
git branch: Shows the branches on git
git checkout: It can be used for switching to between branches
git merge: It can be used for Merge versions
git remote: It shows to remote repositories
git remote add: It can be used for adding a remote repository.
git push: This command pushes the latest version commits to remote
git pull: This command pulls the latest version commits to remote
.gitignore: This file helps us to specify files which not wanted to commit

Before you go you need to install git in your computer. You can see the instruction links in the below.

https://git-scm.com/book/en/v2/Getting-Started-Installing-Git

Let’s get in action…
First, we created a sample folder on our Desktop ( You can create anywhere on your computer. )Let’s name that folder “SampleGit”. Inside of SampleGit folder, we can create sample dummy text file which calls “dummy.txt”. After we successfully created these files we are ready to initialize our git.

Creating Sample Git and dummy.txt

As I mentioned at the top we can initialize our git with this command “git init”.

After we created our repository let’s look at “git status” After we typed “git status” we see No commits yet because of we didn’t add and commit any files.But you can see “dummy.txt” file is in red color because we didn’t add and commit our file into the our repository.

Ok, let’s open our text file added some dummy text and saved it. After done with that now we are ready to add our files with “git add dummy.txt” ( In this command after git add you have to write your file name or if you wanted to add all file in your folder you can use “git add .”, “.” means every file in our folder)

Now we can check git status again. We see the “dummy.txt” file is green. This means this files ready to commit.

After we successfully add our file to repository next step is the commit process so we can do that with “git commit -m “This is the first version of file” “. We always need to specify a message for the commits.

Now we can use “git log” command for the see commit logs. We can see commit 1d906720d8b702…. text on the top. This is the unique key which is created for every commit. We can do revert, merge commands with the first 7 letters of this id. ( You can use all id too). After we typed “git status” you can see there are no red or green color files names because we did commit process successfully

Also, we can see what is the current branch with “git branch”. Because we have only 1 branch, we just saw master with green color. Let’s create another branch with “git branch sample” and see the results.(sample is the branch name you could pick any name)

Now you can see the 2 branches master and sample. Green color means what branch you are in at that moment.
After completing all these steps you created successfully your git repository and committed files on it. I’ll explain the rest of the commands in Part-2. If you have any question please comment in below also if you have any idea about what could be the next story after part-2 you can also write it down so I try to do my best.

Thank you for reading.

--

--