Git for beginners: Basic and essential commands
What is Git?
Git is a tracking software which tracks changes in code with help of commands. Like: git add, git commit, git diff
Why Git is used ?
Git is used to track changes in code. It can be used by many people means it can be used for collaboration.
For example :- Developer A, B and C are working on project so it A made change in code that will be visible to B and C. And each developer has a old copy of that code.
Git Basics and Core Terminologies
Git Basics
Version Control : Keeps a history of changes so if you want to make mistake correct
Repository: A folder where Git tracks files
Branch: A separate workspace without harming main code
Commit : It takes a snapshot of what change I made in code
Merge : Combines changes from different branches.
Remote Repository : It is used for collaboration storing copy of code for all developers
Core Terminologies
Repository: A folder where Git tracks files
Commit : It takes a snapshot of what change I made in code
Merge : Combines changes from different branches
Remote : It is used for collaboration for all developers copy of code
Clone: A local copy of an existing remote repository
Pull : Downloads changes from a remote repository
Push : Uploads local commits to a remote repository
Staging Area : Where changes are prepared before committing
HEAD : A pointer that represents the current branch
Git Commands
git init - creates a new git repository
git add - that moves your changes from working directory to staging area
git commit - m - takes a snapshot of change made in code
git commit - am - Takes snapshot of all modified files
git log- used to display the entire commit history of git repository
git status - It tells changes are made or not
git diff - tells the difference between new and old and new file