Git Cheat Sheet

What is Git

Git is the open source version control system. So basically with git we can keep track of our content. The code which is stored in Git keeps changing as more code is added. Also, many developers can add code in parallel. So Version Control System helps in handling this by maintaining a history of what changes have happened

Let's understand basic git commands which are very necessary and are being used on the daily basis.

Checking the version of git

git --version

This command is used to check version of git.


Initializing git

git init

The git init command adds a local Git repository to the project.


Help from git

git help

This command is used to find any commands.


Adding files to the git repository

git add .     (This command adds all the files )
git add file.txt     (This command adds only specified file)

This command is used to add the file to git.


Commiting changes to the git repository

git commit -m "Initial commit"

This command is used to commit the file. Here "Initial commit " is the message written to get clarity of the commited reason.


Git status

git status

This command is used to check the status of file.


Git log

`` git log git log --author="Shreesha" (This shows the commit from author) git log -n 2 (This shows the number of commits you want to see)


This command shows the log of file.

***


# Adding the remote repository

git remote add origin github.com/YourURL


This adds the file to the specified github URL.

***


# Pushing the code

git push -u origin master ( This command pushes changes to origin)

```

This command pushes the code to master branch.


So that's all for this blog. I hope this is useful.

Feel free to give any feedbacks for the improvement of the blogs.

Thank you.