Learn Git and Github in 5 Minutes
Let's fix this - Why Git Bash and why not Command Line Interface for Windows OS

Hey everyone and Coder Community. I am here again with another interesting article. This article majorly deals with more insightful info, helpful for beginners. Article focus more on git and its existence.
Disclaimer: This is not the cheat sheet, but it is everything you need to know.
Git vs GitHub
Just be sure that GIT != GITHUB
git - Simply, it can be used with in Local Machine. Git is a version control system used for tracking changes in files
github - It can be used in cloud, where contribution of work begins from different mindsets
git existence on Windows OS
Lets understand, what git actually is
Do You Know?
GIT was designed to run on only on UNIX based interfaces like BASH but not COMMAND PROMPT?
Well, if you are worried about UNIX, BASH, COMMAND PROMPT relation with GIT. Then this article is for you.
Lets get started
GITwas designed to run onUNIXbased interface (likeBASH).BASHis a Command Line Interface which is used as default shell forLINUX & MACbased OS.- But, Windows comes with default command line interface called
COMMAND PROMPT. - This
COMMAND PROMPTCLI is not based onUNIX
Now, you might think of, how we can use GIT in Windows
Here is what GIT BASH does.
GIT BASHis a tool that emulates a BASH experience on a windows machine. So, in order to experience GIT on windows, we useGIT BASH
git init
What is git init?
The git init command creates a new Git repository. It can be used to convert an existing, un-versioned project to a Git repository or initialize a new, empty repository.
Well, one thing to be noted here is...
Do not init a
REPOinside anotherREPO
Confused?. Lets understand why I am saying this..
Before running git init, make sure you run git status, to verify that you are not currently inside of a REPO
YES!, you can delete the REPO, if it was created by mistake
Best Advice
Always, Create a Folder for the project and initialize in that folder (git init)
git commit
AHAA...!, before working on git commit, we have to understand the workflow of GIT
Physical Locations - Terminology
Working Directory-> Referred as working project folderStaging Area-> Adding changes to a location, before we commitRepository-> Refers to Git Repository
Workflow
Here is how the entire workflow looks like
- Stage your changes from
Working DirectorytoStaging Areagit add file1 file2 - Verify whether changes are Staged or not i.e.
Staging Areagit status - Commit your changes from
Staging AreatoRepositorygit commit -m “Type message here”
Why not git commit alone
In reality, we can also use git commit, but anyways it prompts for commit message in Text Editor (as configured)
Running git commit will commit all staged changes. It also opens up a text editor(by default vim) and prompts you for a commit message.
it's better to use git commit -m "message", to make things easier.
SETUP git
Know your Version
Open GIT BASH - Know the version of GIT on Local System
git --version
Know your GIT Configuration Values
git config --list
Add Configuration Values
git config --global user.name “Prathap Reddy”
git config --global user.email “prathapsayz@gmail.com"
Tip: - Add Git Bash as default terminal in VS CODE, to work on directly.
Terminal Commands
Let's understand Terminal Commands
ls-> List contents of current directorystart .-> Opens the window of current directoryls foldername-> list contents inside that folderls foldername/subfolder-> list contents inside the subfolder (we cant access subfolder contents, without using path.pwd-> Print the path of current directorycd foldername-> Change the current directory. So called moving from one folder to another foldercd ..-> Go back from Current Directory to Previous Folder (1 Level)touch filename.extension-> Creates a new files of any extension in the directorytouch folder/subfolder/filename.extension-> Create file using folder referencingmkdir foldername-> create a folder in current directorymkdir folder1 folder2-> Creates two folders in current directoryrm filename.ext-> Deletes the file. It permanently removes.rm -rf foldername-> Deletes the folder, permanently (RF – Recursive Force)code .-> Opens entire directory in Text Editor (VS code)git add .-> add all files/content to staging areagit log-> shows the history of commits
Get help with git help
Open GIT BASH and enter following command.
git help
Common Git commands
start a working area (see also: git help tutorial)
clone Clone a repository into a new directory
init Create an empty Git repository or reinitialize an existing one
work on the current change (see also: git help everyday)
add Add file contents to the index
mv Move or rename a file, a directory, or a symlink
restore Restore working tree files
rm Remove files from the working tree and from the index
examine the history and state (see also: git help revisions)
bisect Use binary search to find the commit that introduced a bug
diff Show changes between commits, commit and working tree, etc
grep Print lines matching a pattern
log Show commit logs
show Show various types of objects
status Show the working tree status
grow, mark and tweak your common history
branch List, create, or delete branches
commit Record changes to the repository
merge Join two or more development histories together
rebase Reapply commits on top of another base tip
reset Reset current HEAD to the specified state
switch Switch branches
tag Create, list, delete or verify a tag object signed with GPG
collaborate (see also: git help workflows)
fetch Download objects and refs from another repository
pull Fetch from and integrate with another repository or a local branch
push Update remote refs along with associated objects
That's all for this Article, I hope this article helped you on basics. Go on, dig for more concepts. Happy Learning :)

