Q1. What is Git, and how does it work internally?
Git is a distributed version control system used to track code changes.
It works with three main areas: working directory, staging area, and repository. Developers modify files in the working directory and stage changes using git add.
Commits save snapshots into the repository. This workflow allows safe experimentation and easy rollback of changes.
Q2. What is a Git repository, and what does it contain?
A Git repository stores all project versions and history. It contains commits, branches, tags, and configuration files.
The .git folder holds metadata and object storage. Each commit references a snapshot of files and previous commits.
This structure enables fast branching and merging.
Q3. How does branching work in Git?
Branches allow developers to work on features independently.
Each branch points to a specific commit. Git creates lightweight branches without copying files.
Once work is complete, branches are merged back into the main branch. Branching supports parallel development and safer collaboration.
Q4. How does GitHub support collaboration in teams?
GitHub provides remote repositories for sharing code. Developers push changes and create pull requests.
Pull requests enable code review, discussion, and testing before merging. GitHub also tracks issues, commits, and contributors.
This makes team collaboration structured and transparent.
Q5. Difference between Git and GitHub
| Feature | Git | GitHub |
| Type | Version control tool | Hosting platform |
| Usage | Track code locally | Share code online |
| Internet | Not required | Required |
| Example | git commit | Pull request |
Git manages code history, while GitHub manages collaboration.
Q6. Difference between git clone and git pull
| Command | Purpose | When Used |
| git clone | Copy full repo | First time setup |
| git pull | Update local repo | Ongoing work |
| Data | Full repository | Latest changes |
| Frequency | Once | Many times |
clone is for starting, pull is for syncing.
Q7. Difference between git fetch and git pull
| Command | Action | Merges Changes |
| git fetch | Downloads updates | No |
| git pull | Fetch + merge | Yes |
| Safety | Safer | Risk of conflicts |
| Usage | Review first | Quick update |
fetch is safer for reviewing changes before merging.
Q8. Difference between public and private repositories
| Feature | Public Repo | Private Repo |
| Visibility | Everyone | Selected users |
| Security | Low | High |
| Use Case | Open source | Company projects |
| Access Control | Limited | Full control |
Private repos are preferred for company code.
Q9. What is version control, and why is it important?
Version control tracks changes in code over time. It allows rollback to previous versions. It helps teams collaborate without conflicts.
Git is the most popular version control system today. It improves code safety and productivity.
Q10. What is a commit in Git?
A commit is a snapshot of changes in the repository. Each commit has a unique hash ID.
Commits include message, author, and timestamp. They represent project history. Small, meaningful commits are best practice.
Q11. What is git status used for?
git status shows the current state of the working directory. It tells which files are modified, staged, or untracked.
It helps avoid accidental commits. Developers use it frequently before committing. It is one of the most used Git commands.
Q12. What is git add used for?
git add stages changes before committing. It moves files from working directory to staging area. Developers choose which changes to commit.
This gives control over commit content. Without git add, changes cannot be committed.
Q13. What is git commit -m used for?
This command creates a commit with a message. The message describes the changes made.
Clear commit messages improve project history. Every commit should have a meaningful message. This is essential for team collaboration.
Q14. What is a branch in Git?
A branch is an independent line of development. It allows working on features without affecting main code.
Branches are cheap and fast. Most workflows use feature branches. Branching improves stability and productivity.
Q15. What is merge conflict?
A merge conflict occurs when Git cannot automatically merge changes. It happens when the same file lines are modified.
Developers must manually resolve conflicts. Conflict resolution is a common interview topic. Proper branching reduces conflicts.
Q16. What is .gitignore file?
.gitignore tells Git which files to ignore. It prevents committing logs, secrets, or build files. It improves repository cleanliness.
Each project should include a .gitignore file. It enhances security and performance.
Q17. What is a remote repository?
A remote repository is a version of the project hosted online. GitHub is the most common remote platform. Remotes allow team collaboration. Developers push and pull changes from remotes. It keeps everyone in sync.
Q18. What is git push used for?
git push uploads local commits to a remote repository. It shares changes with the team.
Pushing updates GitHub branches. Without push, changes stay local. Push is required for collaboration.
Q19. What is a pull request in GitHub?
A pull request requests merging changes into another branch. It enables code review and discussion.
Teams review code before merging. Pull requests improve code quality. They are central to GitHub workflows.
Q20. Why is GitHub important for developers?
GitHub enables collaboration, version control, and code hosting. It supports CI/CD, issue tracking, and reviews.
Recruiters often check GitHub profiles. It showcases developer skills. GitHub is essential in modern software development.





