What is git and how to use it effectively

By NavinNavi - Posted on Dec 2018

Responsive image

I made this blog to quickly run you through basics of git and its commands.So let's get started!!!!

What is Git?

What is GitHub?

How does it work?

Three areas of git

Working Directory

Staging Area

Git Repository

Working with Git on Linux

Installing Git

Getting started

Create a new repository
Adding files
Adding multiple files of a certain type
Adding all files in directory (including hidden)
Removing Files that are staged
Ignoring files
Commit the staged files
Log view

Git Branches

image of a main branch and new side branch
Listing all branches
Adding a branch
Changing branches
Merging a branch
Removing a branch

Now comes the final part

Link your Project to github.com

Thanks to Ian Schoonover for the guide.

Working with Github on Windows

Create a Repository

Repositories are used to store folders and files – anything about your project.

  1. Go to github.com
  2. In the upper right corner, next to your avatar , click and then select New repository.
  3. Name your repository.
  4. Write a short description.
  5. Select Initialize this repository with a README.md
  6. Click Create repository
repository creation screenshot repository creation screenshot

Create a Branch

Create a new branch to make a copy of your repository in the master branch as working in new branch wont affect the master.

  1. Go to your new repository.
  2. Click the drop down at the top of the file list that says branch: master.
  3. Type a branch name into the new branch text box.
  4. Select the blue Create branch box or hit “Enter” on your keyboard.
branch creation screenshot

Edit and commit changes

On GitHub, saved changes are called commits.

  1. Click the pencil icon in the upper right corner of the file view to edit.
  2. In the editor, write a bit about yourself.
  3. Write a commit message that describes your changes in new branch.
  4. Click Commit changes button.
edited screenshot commited screenshot

Open a Pull Request

  1. Click the Pull Request tab and click the green New pull request button.
  2. Look over your changes in the diffs on the Compare page.
  3. Click the big green Create Pull Request button.
  4. Give your pull request a title and write a brief description of your changes.
pull request screenshot pull confirm screenshot

Merge your Pull Request

  1. Click the green Merge pull request button to merge the changes into master, after the code review and approval.
  2. Click Confirm merge.
  3. Now that your changes are pushed to master, go ahead and delete the branch. If you wish!!!
merging screenshot

Complete flow

complete flow complete flow
Thanks to GitHub Guides for the article reference.

Finally, I hope this post was valuable for you so please, please share your feedback and suggestions to help me improve.