Introduction to Git.

Today I am going to explain how to push files and folders through the terminal to git. It’s pretty simple when you get a hang of it. So let’s start.

I will start with what is Git and Github.

what is GIT ?

Git is a version control system that is used for software development and other version control tasks. As a distributed revision control system it is aimed at speed,data integrity, and support for distributed, non-linear workflows.

What is GITHUB ?

GitHub is a web-based Git repository hosting service. It offers all of the distributed version control and source code management (SCM) functionality of Git as well as adding its own features.”


Let’s get started.

Step 1: Firstly we need to setup Git on our machine.

in ubuntu:

Sudo apt-get install git

Step 2: Second we need to create a GitHub account.

Register into GitHub for free.

Step 3 : Create a new repository

Go to Your repositories at the right side of the window and click on the new repository. Give the name of the repository what you want and make the repository public. Then click on Create repository.

Step 4: Setting up for pushing files to Github.

Copy the https link because we are going to push files and folders via https link. You can follow the inbuilt tutorial on GitHub for pushing or follow this blog.

  1. Open terminal (ctrl+alt+T).
  2. Go to your directory using ‘cd’ command in terminal and follow the next steps as follows.
  3. Type in git init : Create an empty Git repository or reinitialize an existing one.This command creates an empty Git repository – basically a .git directory with subdirectories for objects and template files. An initial HEAD file that references the HEAD of the master branch is also created.
  4. git add filename.extension or folder name : This command updates the index using the current content found in the working tree, to prepare the content staged for the next commit. It typically adds the current content of existing paths as a whole, but with some options, it can also be used to add content to only part of the changes made to the working tree files applied, or remove paths that do not exist in the working tree anymore.
  5. git commit -m “message you want” : This shows the message on the file you had pushed.
  6. git remote add origin <link of repository copied from https>  : This command links the repository in  GitHub with our files in our system.
  7. git push -u origin master : This command at last pushes the file or folder to Github.

Note: If you want to see the status of what all  have happened to your files in GitHub repository you can use the command ‘git status‘.

Hence your files or folders got pushed to Github.



4 thoughts on “Introduction to Git.

  1. if the repo has more than one contributor, how do i push files without pull… or can i refrain from pulling specific files to my local repo and push files to the server?


    1. I find that you are not that much familiar with the terms push and pull of Git. I’d rather strongly suggest you look upon it much more. What are the implications of both 🙂

      I might answer you a wild guess maybe. Read the rest after googling upon them and got a perfect sense of it.

      It is irrelevant for pulling files or the diffs from a repo if it has many contributors. You could pull anytime from a repo. But pushing into a repository where you don’t have access to, it would lead you not able to push your changes. At that time we do a pull request to ask the maintainer or some of the contributors of the repo to merge your pull request if the changes are correct enough that it won’t break the whole system. Let me get you clear here, I hope you know read and write access. Pull and Push uses something similar methodology. For Pushing a file you need write access while for pulling a you just need the read access.

      Now let’s tackle the second query on mere guess again, You could push files without pulling the existing changes, But make sure that the changes you are doing don’t contradict with the changes that might be done in the master.

      Hope this helps. And please try to keep your questions clear and understandable. So that I could help more much more. And try to form them better. A question with better explanation won’t hurt much.

      Thanks 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s