3.GIT
3.GIT
3.GIT
1. What is Git?
A version control system for tracking changes in source code during
software development.
2. What is GitHub?
GitHub is an internet hosting service that provides version control and
collaboration tools for developers.
3. Popular Git Hosting Services:
1. Local: Has a database that stores all file changes under revision
control.
2. Centralized: Has a single repository - each user receives their
working copy (e.g., CVCS).
3. Distributed: Multiple repositories - different users can access each
one with their working copy (e.g., Git).
5. Difference Between Git and GitHub:
Git is the version control software, while GitHub is a web-based platform
that provides hosting for Git repositories.
6. Git Workflow:
1. Working Directory,--> local copy of your project
2. Staging Area, --> intermediate step where we can made changes
before commiting history
3. Repository.
Changes are made in the working directory, staged using git add to
move them to the staging area, and committed to the repository using
git commit.
1. What is a Repository?
A storage space where Git stores the history and multiple branches of
your project.
2. How to Initialize a Repository in Git:
Use the git init command.
3. Git vs Subversion (SVN):
Git is distributed and decentralized (each developer have complete copy
of repository), while SVN is centralized (Single repository).
Git - stores content in form of metadata SVN- stores data in form of files
4. What is a Commit?
A snapshot of changes made to a project; a save point in Git.
Mid-Level:
1. Basic Commands:
ls: List files.
ls -a: List all, including hidden files.
git init: Initialize a .git file for project history.
git add <filename>: Stage files for commit.
git reset <filename> or git rm --cached <filename>: Unstage files.
git commit -m "<message>": Commit changes.
4. Git Stash:
git stash: Temporarily store changes.
git stash pop: Retrieve changes from stash.
git stash clear: Clear all changes from stash.
5. Remote Operations:
git remote add origin <link>: Link local repo to a remote repo.
git push origin master: Push changes to the master branch.
6. Branching:
git branch <name>: Create a new branch.
git checkout <branch>: Switch to a specified branch.
git merge <branch>: Merge changes from a branch.