Git Usage Guide and Features
1. Installation:
2. Configuration:
git config --global user.name "Your Name"
and git config --global user.email "youremail@example.com"
.3. Initializing a Repository:
git init
in an empty directory or clone an existing one with git clone <repository URL>
.4. Basic Commands:
git add <file>
: Add changes to the staging area.git commit -m "Commit message"
: Commit staged changes with a descriptive message.git status
: View the current status of your repository.git log
: See the commit history.git diff
: View the differences between your working directory and the last commit.5. Branching:
git branch
: List all branches in the repository.git branch <branch-name>
: Create a new branch.git checkout <branch-name>
: Switch to an existing branch.git merge <branch-name>
: Merge changes from one branch into the current branch.6. Remote Repositories:
git remote add origin <remote-url>
: Link your local repository to a remote one.git push
: Send local changes to the remote repository.git pull
: Fetch and merge changes from the remote repository.7. Undoing Changes:
git reset <file>
: Unstage changes from the staging area.git checkout -- <file>
: Discard changes in a file and revert to the last commit.git revert <commit>
: Create a new commit that undoes changes introduced by a specific commit.8. Collaborating:
Git Features:
1. Distributed Version Control:
2. Efficient Branching and Merging:
3. Lightweight and Fast:
4. Content-Addressable Filesystem:
5. History Tracking:
6. Staging Area:
7. Security and Integrity:
8. Easy Collaboration:
By mastering Git and its features, you can efficiently manage your codebase, collaborate effectively, and maintain a well-documented history of your project’s development.