Complete Git and GitHub

Complete Git and GitHub

ยท

4 min read

What is Git?

Git is an open-source distributed version control system. it helps you to keep track of code changes and use it for sharing code to manage multiple versions of source code.

Install git from here.

Why Git and What Does Git Do?

  • Git manages a project with Repositories like cloning, staging, committing, branching, merging, pulling, pushing to local update to the main project

  • Git is used by more than 70% of developers. Developers can work together from anywhere in the world. developers can see the full history of the project, and have the ability to return to a previous version if needed.

Types of version control system

Centralized VersionDistributed Version
Centralized version control is the simplest form of version control in which the central repository of the server provides the latest code to the client machinesDistributed version control is a form of version control where the complete codebase including its full history is mirrored on every developer's computer
There are no local repositoriesThere are local repositories
Works comparatively slowerWorks faster
A failure in the central server terminates all the versionsA failure in the main server does not affect the development

What is GitHub?

Git is not the same as GitHub. It is the largest hosting platform that serves as a location for uploading copies of the Git repository

Go to GitHub and sign up for an account:

Create a Repository on GitHub

After sign in, create a new Repo:

Please provide the necessary information:

please select either Public (if you want the repository to be visible to everyone) or Private (if you want to control who has access to view the repository). Regardless of your choice, you will have the ability to choose who can contribute to the repository. Once you have made your selection, click on "Create repository".

Push Local Repository to GitHub

To proceed, we will now push the local Git repository to GitHub.

Follow all the procedures given in the above image.

Git Commands :

git --version     # it shows you git version
git config --global user.name "Your Name"   # add your name
git config --global user.email "Your Email"   # Add your email address that is linked to your GitHub account.
mkdir myproject    # create reposotory
cd myproject  # enter into the repository
git init  # Initialized empty Git repository for tracking
git status  # see untracked file for tracking for checking and giving information
git add "File_Name" # track perticular file
git add --all  # track all file
git commit -m "First release of Hello World!"  #keep the track of version of file
git branch  # see all branches
git checkout -b hello-world-images  #create and shift to given the branch
git branch hello-world-images  #only shift to branch
git checkout hello-world-images #only shift to branch
git merge "branch_name" # merge the other branch code to master branch
git diff "file name"  # show difference of what changes has been made in privious and current file 
git log ## see all commit
git reset --hard "commit _id"  #it will back you to the privious commit/version
git push # push your  code on github
git remote add # To verify that the remote repo was added to your configuration
git remote -v 
git clone "GitHub_REPO_URL" # Clone github repository in your local system
git cherry-pick "commit_id"  #changes has been made in other branch will merge in master branch

Thank you so much for taking your valuable time to read

After being inspired by Kunal Kushwaha and his tutorials, I decided to take the initiative to learn in public and share my work with others. I made an effort to present the information in a simple and concise manner. I hope that you were able to learn something new from my work today.

We welcome any feedback that can help us improve. Thank you!

Follow me on Twitter, Linkedin, and GitHub.

Happy Learning ๐ŸŽ‰๐ŸŽ‰

ย