# 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](https://cdn.hashnode.com/res/hashnode/image/upload/v1658677577915/GFrphOFqs.png align="left")

> 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](https://cdn.hashnode.com/res/hashnode/image/upload/v1658677943930/-UqocPG2I.png align="left")

> 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](https://cdn.hashnode.com/res/hashnode/image/upload/v1658678184756/iKQia45mf.png align="left")

> Step-4

![token generated.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1658678373749/2kaI46vuX.png align="left")

 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](https://cdn.hashnode.com/res/hashnode/image/upload/v1658661506138/gJjAlIbM8.png align="left")

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](https://cdn.hashnode.com/res/hashnode/image/upload/v1658662125913/albG0zWyF.png align="left")

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](https://cdn.hashnode.com/res/hashnode/image/upload/v1658675814601/wMNQqkYvD.png align="left")

> Step-2

```
$ ls
```

![ls.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1658675914567/xw8hql5h1.png align="left")

> Step-3

```
$ git init
```

![init.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1658675964549/QazbqK31s.png align="left")

> 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](https://cdn.hashnode.com/res/hashnode/image/upload/v1658676293095/DySDNlqSf.png align="left")

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

```
$ git status
```

![git status 2.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1658676429652/m1T_MKFMI.png align="left")

>> Here we can see there is no Untracked file.

---
> Step-6

```
$ git commit -m "first commit"
```

![commit.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1658676614630/yxGEamMdt.png align="left")

> Step-7

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

![remote origin.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1658676857228/je0-1eMz6.png align="left")

> Step-8

```
$ git push -u origin master
```

![push.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1658676973782/dKL-k2Me6.png align="left")

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](https://cdn.hashnode.com/res/hashnode/image/upload/v1658677172027/aS-zrMbsJ.png align="left")

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...
