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:
Command | Description |
git init | Initialize a new Git repository |
git clone | Clone a repository from a URL |
git status | Show the status of the working directory |
git add | Stage a file for commit |
git add . | Stage all changes in the current directory |
git commit -m "message" | Commit staged changes with a message |
git push | Push commits to a remote repository |
git pull | Fetch and merge changes from a remote repo |
git branch | List branches |
git branch | Create a new branch |
git checkout | Switch to a specific branch |
git merge | Merge a branch into the current branch |
git log | View commit history |
git diff | Show differences between working files |
git reset | Unstage a file |
git stash | Save changes without committing |
git stash pop | Reapply stashed changes |
git remote add | Add a remote repository |
git fetch | Download objects and refs from another repo |
git rebase | Reapply 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