Git/github Detail

What is VCS?

VCS is a version control system. VCS stands for Version Control System. It is a tool that helps manage and track changes to source code or other files over time. VCS is essential for software development and other projects where maintaining a history of changes, collaboration, and versioning is critical

EXAMPLE OF VERSION CONTROL SYSTEM:

1.Most popular one is Git.

2. Mercurial

3.Subversion (SVN)

4.Perforce

Why we use the VCS(VERSION CONTROL SYSTEM)?

 Tracking Changes: It records changes to files over time, enabling developers to see who changed what and when.

 Collaboration: Multiple people can work on the same project simultaneously without overwriting each other’s work.

 Branching and Merging: Developers can create separate branches for different features or experiments and later merge them into the main project.

 Version History: It keeps a history of all changes, making it easy to revert to previous versions if needed.

 Conflict Resolution: Helps manage and resolve conflicts when multiple developers make changes to the same file.

 Backup and Recovery: Acts as a backup for the project.

Introduction of Git:

Git is a version control system VCS designed to track changes in source code and collaborate efficiently with others. It is widely used for software development due to its speed, flexibility, and support for non-linear workflows (e.g., branching and merging).

WORKFLOW OF GIT:

Git Cheat Sheet:

CommandDescription
git initInitialize a new Git repository
git cloneClone a repository from a URL
git statusShow the status of the working directory
git addStage a file for commit
git add .Stage all changes in the current directory
git commit -m "message"Commit staged changes with a message
git pushPush commits to a remote repository
git pullFetch and merge changes from a remote repo
git branchList branches
git branchCreate a new branch
git checkoutSwitch to a specific branch
git mergeMerge a branch into the current branch
git logView commit history
git diffShow differences between working files
git resetUnstage a file
git stashSave changes without committing
git stash popReapply stashed changes
git remote addAdd a remote repository
git fetchDownload objects and refs from another repo
git rebaseReapply commits on top of another branch

GIT WORKFLOW:

What is .git/ Directory?

As soon as we run git init command, we get following message in the console:

Initialized empty Git repository in /home/Coding/piyushgarg-dev/projects

Let's look at what is in the .git folder

config is a text file that contains your git configuration for the current repo.

HEAD contains the current head of the repo.

hooks contain any scripts that can be run before/after git does anything.

objects contains the git objects, ie the data about the files, commits etc in your repo.

We will go in depth into this in this blog.

refs as we previously mentioned, stores references(pointers