Git Important Points
Git Important Points
1. Git Basics
- Repository (Repo): A directory containing all your project files and their history.
- Commit: A snapshot of changes made to files.
- Branch: A separate line of development.
- Merge: Combining changes from one branch into another.
- Clone: Copying an existing repository.
4. Undoing Changes
- git checkout -- <file> - Discard changes in a file.
- git reset --soft <commit> - Undo commits but keep changes staged.
- git reset --hard <commit> - Completely reset to a previous commit.
5. Working with Remote Repositories
- git remote add origin <url> - Link a local repo to a remote.
- git fetch - Get latest changes from a remote repo.
- git rebase - Reapply commits on top of another base commit (use carefully).
6. Git Ignore
- Use a .gitignore file to exclude unnecessary files from tracking.
7. Best Practices
- Write clear commit messages.
- Commit small, logical changes frequently.
- Always pull before pushing to avoid conflicts.
- Use branches for separate tasks.