1. What is Git?
Git is a distributed version control system used to track changes in source code during software development.
2. What is GitHub?
GitHub is a cloud-based platform used to host Git repositories and collaborate on projects.
3. What is the difference between Git and GitHub?
| Git | GitHub |
| Version control tool | Hosting platform |
| Works locally | Works online |
| Tracks code changes | Enables collaboration |
4. What is a repository in Git?
A repository is a storage location that contains project files and version history.
5. What is a local repository and remote repository?
| Local Repository | Remote Repository |
| Stored on local machine | Stored on server/GitHub |
| Used for local work | Used for team collaboration |
6. What is a commit in Git?
A commit is a snapshot of changes saved to the repository.
Example:
git commit -m "Added login feature"
7. What is the difference between git pull and git fetch?
| git pull | git fetch |
| Fetches and merges changes | Only downloads changes |
| Updates local branch automatically | Does not merge automatically |
8. What is the difference between git merge and git rebase?
| git merge | git rebase |
| Combines branches with merge commit | Rewrites commit history |
| Preserves history | Creates cleaner history |
9. What is branching in Git?
Branching allows developers to work on features independently without affecting the main code.
10. What is a merge conflict?
A merge conflict occurs when Git cannot automatically merge changes from different branches.
11. How do you resolve merge conflicts in Git?
Steps:
- Open conflicted files
- Edit and resolve conflicts
- Save files
- Run : git add & git commit
12. What is Git staging area?
The staging area is an intermediate area where changes are prepared before committing.
13. What is the use of git add command?
It adds changes to the staging area.
Example:
git add file.txt
14. What is the use of git commit command?
It saves staged changes into the repository history.
15. What is the use of git push command?
It uploads local commits to the remote repository.
Example:
git push origin main
16. What is the use of git clone command?
It copies an existing remote repository to the local machine.
Example:
git clone <repository-url>
17. What is the use of git status command?
It shows:
- Modified files
- Staged files
- Untracked files
18. How do you create a branch in Git?
git branch feature
18. How do you delete a branch in Git?
git branch -d feature
19. What is a pull request in GitHub?
A pull request is a request to merge code changes into another branch
20. What are the advantages of Git?
- Fast performance
- Distributed system
- Easy branching
- Strong version tracking
- Collaboration support