Navigate back to the homepage

An another intro of Git

Divyansh Tripathi
September 2nd, 2018 · 4 min read

My terminal is sexy and i know it.

An another intro of Git.

Git can be a real pain in the posterior regions of yours when you are new to it. There are thousands of blogs explaining what is git…But i’ve tried my level best to make it different from them. So you can really answer this :-

Bro, do you even GIT it ?

What is Git?

Git is a version control system (VCS) . It is generally used to keep track of revisions and allow a developer or dev team to work together on a project through branches.

Outside code development it is also used for keeping track of non-binary files such as financial reports.

Git is not GitHub. Git is the system, and GitHub is a repository hosting service (the most popular of many).

Tower, SourceTree, Github for Mac/Windows — these are all GUIs, or Graphical User Interfaces. A GUI is a program that utilizes graphics to create a user-friendly experience, such as Windows to MS-DOS. These programs are useful to learn, especially in a team environment, but in this article, we’re going to do everything through the command line. Don’t worry, it’ll be great.

After all this technical introduction i know what you are thinking….


It’s okay ,i felt the same :)

So what we’ll do is

  • We’ll make one github repo on our own and learn what does all these technical jargons mean .
  • Follow along ,life will be a little simpler now…atleast the part of your life which includes GIT.

Step 1: Installation


Open the Terminal program. Type git — version and press enter. If a version number is returned, Git is already installed. If something along the lines of -bash: git: command not found pops up, install Xcode from the App Store.

In XCode, install Command Line Tools: > Preferences > Downloads > Command Line Tools. You can now use Git through Terminal.

Although it’s not necessary for the rest of this article, now would be a good time to install Homebrew — a tool for simplifying the installation and management of dev tools.


Download Git for Windows. You will be using the Git Bash program. It will utilize all the same commands as Terminal.

Step 2: Create an Online Git Repository

GitHub is the most popular location to host repositories, so go ahead and make an account there if you haven’t.

I’ll assume your username is kamlesh. This would make your new GitHub

Once you’ve made your account, create a repository by clicking Add New Repo. Do not initialize with a or .gitignore at this point. We can call the repository project. Your repository has been created at It should be completely empty.

Step 3: Create a Local Project

If you’re not at all familiar with the command prompt, please read the first chapter or two of the command line crash course or you can follow along the article and come back to it again later.

Here are the most important commands, and all you need to know to get started.

Basic command line reference

  • pwd Print Working Directory — shows the exact directory you’re working in.
  • ls List Directories — lists all the files and folders in your current directory.
  • cd Change Directory — change to another directory.
  • mkdir Make Directory — create a new directory.

Remember, Terminal (Mac) and Git Bash (Windows) are both command line shells. Any Git related Shell commands can be done the same through both.

When you open Terminal, you will start off in your main directory. I will assume your computer has the same username as your GitHub account.

Now open git bash(if on windows) or terminal(if on OSX or Linux) and type the following command and hit enter after each.

The code written succeeding (->) is the output of your command, you need not type that.

  1. Confirm your location.
2--> /Users/you

2. Create a new folder called project-local.

1mkdir project-local

3. List your directories.


You should see project-local in the list of directories. Of course, you could have created the directory through Finder or Explorer, but it’s a useful command to know.

4. Move into the newly created directory.

1cd project-local

Now you’re in the folder where your local project and Git repository will live. From here, we will begin using git commands. There is a massive amount of commands for Git, but we only need a few to get started.

Basic Git command reference(Not to be used now ,just for reference)

  • Config:-
1git config
  • Initialize Git repository
1git init
  • Check the status of a Git repository
1git status
  • Track files
1git add
  • Commit tracked files
1git commit
  • Upload files
1git push
  • Download files
1git pull

All of the future commands we do today will only apply to your local Git environment. However, there is one important global step to take before doing anything else — configure your Git account.

5. Configure your global Git account.

1git config --global “Firstname Lastname”
2git config —-global

Make sure you’re still in the project-local folder, then move on.

6. Initialize Git repository.

1git init

Initialized empty Git repository in /Users/you/project-local/.git/

Great! Now you have an empty Git repo on your local computer.

7. Hook up local directory with the repo we made at

1git remote add origin [](

Terminal won’t respond, but it was successful. Go ahead and add a file to the project-local directory. You can add as many files as you want, but I will assume you added two files –index.html and style.css.

8. Check the status of your local repository.

1git status
3\-->On branch master
4\-->Initial commit
6\-->Untracked files:
7\-->(use “git add …” to include in what will be committed)
12\-->nothing added to commit but untracked files present (use “git add” to track)

Okay, so now it knows that there are two files in the directory, but they’re not a part of the Git repo. At this point we have to track the files with the add command.

9. Add ALL the files to the repo. (case sensitive command!)

1git add .

Let’s check the status again with git status.

1\-->On branch master
2\-->Initial commit
4\-->Changes to be committed:
5\-->(use “git rm –cached …” to unstage)
7\-->new file: index.html
8\-->new file: style.css

So, what did that do? The files are green now instead of red. Are we ready? Not quite yet.

10. Commit tracked files to the master branch

1git commit -a -m “Initial Commit”
3\-->\[master (root-commit)\] Initial
4\-->2 files changed, 34 insertions(+)
6\-->create mode index.html
7\-->create mode style.css

With this command, I commit all the files (-a), include a message (-m), listed here (“Initial Commit”). Everything in this line is mandatory.

Do not forget to add a comment when you commit your files. Strategic commenting in Git is as important as commenting code. If you accidentally forget to add a comment and end up in a strange screen where you can no longer enter any commands, press ESC and type :q! followed by ENTER.

11. Push the files to the Git repo at

1git push origin master

Terminal will prompt you to enter your GitHub username and password. When you type in your password, it might not show that you’ve typed anything, but it’s being entered.

Now refresh your GitHub page. Success! All your files are now hosted at!



Join my email list and get notified about new content

I promise I won't spam or unnecesarily promotional emails through this mailing list. You might also get chance to be eligible for my monthly giveaways. Also I promise to not spam your inbox or share your email with any third parties.

More articles from Silentlad

Systemd timers onCalendar (cron) format explained

Learn the format of onCalendar for systemd timers, systemd timer every 15 minutes, systemd timer every week, systemd timers every day

October 10th, 2021 · 2 min read

How to use systemd timers (cronjob alternative)

Learn how and why to use systemd timers to schedule scripts, jobs on your unix based systems

October 7th, 2021 · 2 min read
© 2018–2021 SilentladSitemapRSS feed
Link to $ to $ to $ to $ to $ to $