A Cheatsheet on GIt & GITHUB

A Cheatsheet on GIt & GITHUB

What is Git

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

What is the purpose of Version Control

The purpose of version control is to allow software teams to track changes to the code while enhancing communication and collaboration between team members. Version control facilitates a continuous, simple way to develop software.

What is Github

GitHub, Inc. is a provider or platform of Internet hosting for software development and version control using Git. It is used for hosting and collaborating on Git repositories.

let's quickly go through with git's all necessary commands...

Install Git for All Platforms

https://git-scm.com/

Setup git repository in your local system

Configuration

For current configuration

$ git config --list

Show repository configuration

$ git config --local --list

Same for Global and system list, just place those instead of --local


Sets the name you want to be attached to your commit transactions

$ git config --global user.name "[name]"

Sets the Email you want to be attached to your commit transactions

$ git config --global user.name "[email address]"

Generate your Token Before creating any Repository

Step-1

settings.png

Step-2

Go to the bottom left side corner of your setting, Click on Developer Setting then go to Personal access token, After that click on Generate new token.

generate token.png

Step-3

Then you can create a token name and set a time limit to access that token will be generated.

generate token name.png

Step-4

token generated.png

This is it... Now you can create your Repository.

Create Your First Repository

First You need to Signup with GitHub, After login in with your account, go to the + icon.

Screenshot 2022-07-24 164644.png

After this, you can redirect to the below page, create your repo name, and make it public or private as your choice, you can also create a readme file, and then click Create repository

Screenshot 2022-07-24 165151.png

Then you can open your Git Bash or any other command line, in the specific folder you want then initialize the git repository by running the below command.

Step-1

 $ git status

git status 1.png

Step-2

$ ls

ls.png

Step-3

$ git init

init.png

Step-4

For adding all files inside a folder.

$ git add .

For adding a single file inside a folder

$ git add Your-repo.txt

add.png

Step-5

You can check git status again to confirm, it's all up to you.

$ git status

git status 2.png

Here we can see there is no Untracked file.


Step-6

$ git commit -m "first commit"

commit.png

Step-7

$ git remote add origin https://github.com/Deep9110/Your-Name.git

remote origin.png

Step-8

$ git push -u origin master

push.png

Here all done, now you can check your GitHub repository to whether that file was added or not. Let's see the repo that we created.

published repo.png

It shows that we have successfully pushed our code to GitHub.

Thanks for giving your valuable time on learning git commands. If you like my Blog give a like and Save it for later use...