Welcome to my Git Learning Repository! This comprehensive guide will take you through the fundamental concepts of Git, providing in-depth explanations and real-world examples along the way. Let's dive into the world of version control!
- What is Git?
- Why Use Git?
- Key Terminology
- Git Basics
- Branching
- Stashing Changes
- Reset and Revert
- Tags
- GitHub Integration
Git is a distributed version control system that tracks changes in your code. It allows multiple developers to collaborate efficiently on a project, keeping a history of all changes made.
- Version Control: Git enables you to track changes and revert to previous states of your project.
- Collaboration: Collaborate seamlessly with others by sharing and merging code changes.
- Backup: Store your project on remote servers like GitHub for backup and collaboration.
- Branching: Create isolated development branches for features or bug fixes.
- Community: Join a vast community of developers who use Git for open-source projects.
A Git repository is a folder that contains all the files and the history of your project.
The working directory is where you create, edit, and organize your project's files.
The staging area is where you prepare changes for committing.
The local repository stores all the project's history on your computer.
To create a new Git repository, run: git init This initializes a new Git repository in the current directory.
Adding Files (Staging) git add <file(s)> Staging prepares changes to be included in the next commit
Committing Changes Commit changes with: git commit -m "Your commit message" Commits save your changes to the Git history.
Pushing and Pulling**** Push your changes to a remote repository: git push origin
Pull changes from a remote repository: git pull origin
Branching Creating a Branch Create a new branch with: git branch
Switching Between Branches Switch to a different branch: git checkout
Merging Branches Merge changes from one branch into another: git merge
Resolving Conflicts Conflicts occur when Git can't automatically merge changes. Resolve conflicts by editing the affected files and then committing the changes.
Stashing Changes Stash Commands Stash your changes for later use: git stash
List stashes: git stash list Apply a stash: git stash apply
Reset and Revert Resetting Commits Undo commits with: git reset
Reverting Commits Revert commits with: git revert
Tags Creating Tags Create a lightweight tag: git tag
Viewing Tags View all tags: git tag
GitHub Integration
Clone a repository from GitHub: git clone
Pushing Changes to GitHub Push your local changes to GitHub: git push origin
Pulling Changes from GitHub Pull changes from GitHub: git pull origin