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.
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.
- Open terminal (ctrl+alt+T).
- Go to your directory using ‘cd’ command in terminal and follow the next steps as follows.
- 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.
- 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.
- git commit -m “message you want” : This shows the message on the file you had pushed.
- git remote add origin <link of repository copied from https> : This command links the repository in GitHub with our files in our system.
- 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.