Let's understand git & github

This is the beginner's guide to understanding git, There are many git clients for git. The technology is the same no matter what the client is. But in this article, we will use GitHub to understand git.

So let's get started! πŸ˜‰

What is Git ? and why do we use it. πŸ€·β€β™‚οΈ

Git is a version control system that is used for tracking changes in computer files and co-ordinate work on these files with multiple people. Git is distributed version control system. you can imagine it as a history tab for the code you have written, It helps you to keep track of the changes. If at any point while working on your code if you are facing any issues then you easily go back to the stable version that is working fine, so it helps debug, and while working with several people you know who wrote this crap πŸ˜‘, and having access to that information is worth sometimes.

That's enough let's do some practical ✌️

1. First, make a GitHub account

If you don't already have one, make It here

2. Make sure you have git installed on your machine

  • To check that on Windows machine through cmd type

    c:\user\Rushikesh> git --version
    

    image.png If you got this output you are good to go. [ your version number might be different, so please ignore that ]

  • If you are running Linux (deb)

    • To check whether git is installed or not use
      $ git -v
      
    • To install git use
      $ sudo apt install git-all
      

3. Config the git

You have to configure git using your username & email id, Let's see how we can do that.

$ git config --global user.name "YOUR_USERNAME"

$ git config --global user.email "YOUR_EMAIL"

$ git config --global --list # To check the info you just provided

4. Let's use git

Create a new repository on GitHub, Follow this Now locate the folder in your terminal or cmd and use

$ git init           # Initiates an empty git repository

Create files or projects in that located folder

5. Add files to the staging area

Now to add files to the git repository for commit use.

$ git add .  
// Adds all the files in the local repository and stages them for commit

// OR if you want to add a specific file

$ git add FILENAME
// example **git add README.md**
// To add a specific file

6. To check whether the correct files are in the satging area.

$ git status // Lists all new or modified files to be committed

7. Commit changes to your repo.

$ git commit -m "First commit"
// The message in the " " is given so that the other users can read the message and see what changes you made
// Don't forget to use the message

8. Add a remote origin and push

you have to set the remote location to your files

$ git remote add origin remote_repository_URL
// sets the new remote
  • Finally push to the origin 😍
    $ git push -u origin master 
    // pushes changes to origin
    

    These are the basic requirements to use git and manage your project

Β