Introduction to Git: Git is a distributed version control system used for tracking changes in source code during software development. It enables multiple collaborators to work on the same codebase simultaneously while maintaining a history of changes, making it easier to manage, collaborate, and track progress.
Key Concepts:
Repository: A repository (repo) is a collection of files and directories along with their complete history of changes.
Commit: A commit is a snapshot of the repository at a specific point in time. It contains changes made to files, a timestamp, and a commit message explaining the changes.
Branch: A branch is a separate line of development that allows you to work on features, bug fixes, or experiments without affecting the main codebase. The default branch is usually called "master" or "main."
Merge: Merging combines changes from one branch into another. It's commonly used to integrate feature branches back into the main branch.
Pull Request (PR): In a collaborative setting, a pull request is a request to merge changes from one branch (often a feature branch) into another (typically the main branch). It allows for discussion, code review, and testing before changes are merged.
Basic Git Commands:
git init : Initialize a new Git repository.
git init
git clone: Create a copy of a remote repository on your local machine.
git clone <repository_url>
git add: Stage changes for commit.
git add <filename>
git commit: Create a new commit with staged changes.
git commit -m "Commit message"
git push: Upload local commits to a remote repository.
git push origin <branch_name>
git pull: Fetch remote changes and integrate them into the current branch.
git pull origin <branch_name>
git branch: List, create, or delete branches.
git branch git branch <branch_name> git branch -d <branch_name>
git checkout: Switch to a different branch or commit.
git checkout <branch_name>
git merge: Combine changes from one branch into another.
git merge <source_branch>
git pull request: Create a pull request on platforms like GitHub or GitLab.
This command doesn't exist directly in Git. You perform this action on the platform where your remote repository is hosted.