Git for Beginners
Before starting with Git, lets understand what version control system(VCS) means, how it helps to accelerate the development work.
what is VCS?
A system that records the changes to files over time, allowing user to revert to a specific previous versions or review the project history.
Distributed Architecture in VCS: Unlike older, centralized system every developer has local copy of entire project history, this allow developers to work offline independently.
What is git?
Git is free, open source distributed version control system used to track changes in computer files(most commonly source code file in software development). It allows multiple people to collaborate on a project efficiently without overwrutting each other work.
What is difference between Git and Github?
Git → locally installed open source version control system.
Github → is web based platform that hosts git repositories and provide collaborate features.
Commonly used/core git terminologies.
Git Repository
It is directory that contains git and working directory that contains all files tracked by git and git repository is placed where all files are stored.
Git Working Reoistory
It is directory that contains all the files that are tracked by git.
Branch
Branch can be thought as an copy of main/working direectory, whenever developer start working on any project, it creates branch)i.e copy of code) and work independently and in isolated enviroment.
Checkout
This is the process/command to switch between branches generallywhen developers are working on multiple features, they create seperate branch for developmen of each feature, when they need to change/switch branch checkout command is used.
Merge
It is the process that involves merging of code from one branch to another branch.
Pull
It is the process to pull the changes from remote branch)from github/web/cloud) to local branch
Push
It is the process to push all/comitted changes from local branch to remote branch.
Basic Hit Commands
Creating new repository
git init projName
Clone (Copy)an existing Repo
git clone RepoName
Prepare file to commit
Add untrack file/umstaged changes to stage
git add filename
Choose which parts of file to stage
git add -p
Delete file
git rm filename
Commit
git commit -m “commit message”
Move between branch
(moving/switch to particular branch from current branch)
git checkout branchName
git list of branches
git branch
Delete Branch
git branch -d branchName
Discard the changes
git restore fileName