0% found this document useful (0 votes)
3 views2 pages

Git Basics Lab Assignment Guide

The document outlines a comprehensive lab assignment on Git basics, including a mini practical project with steps for initializing a repository, creating branches, and managing commits. It also contains written questions and answers covering key Git concepts such as staging, committing, branches, and the purpose of the .git folder. Overall, it serves as a guide for understanding and using Git effectively.

Uploaded by

omar hamed
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Git Basics Lab Assignment Guide

The document outlines a comprehensive lab assignment on Git basics, including a mini practical project with steps for initializing a repository, creating branches, and managing commits. It also contains written questions and answers covering key Git concepts such as staging, committing, branches, and the purpose of the .git folder. Overall, it serves as a guide for understanding and using Git effectively.

Uploaded by

omar hamed
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Git Basics – Comprehensive Lab Assignment

SECTION 1 – MINI PRACTICAL PROJECT (Screenshots Placeholder)

Step 1 – Initialize Repo: [Screenshot 1]


Step 2 – Create Branch: [Screenshot 2]
Step 3 – Two Commits on Main: [Screenshot 3]
Step 4 – Two Commits on Branch: [Screenshot 4]
Step 5 – Checkout Old Commit: [Screenshot 5]
Step 6 – Return to Main: [Screenshot 6]
Step 7 – Delete Branch: [Screenshot 7]

SECTION 2 – WRITTEN QUESTIONS

Q1: What does git init do?


A1: It creates a new Git repository by generating a .git folder that stores all history and
configuration.

Q2: Difference between staging and committing?


A2: Staging selects changes for the next commit; committing permanently records them in the
repository.

Q3: What is a detached HEAD?


A3: It means you are viewing a commit directly instead of a branch, so new commits have no
branch reference.

Q4: Command to show all branches?


A4: git branch

Q5: Create and switch to a branch immediately?


A5: git checkout -b branchname

Q6: Command to show history in one line?


A6: git log --oneline

Q7: Does deleting a branch remove code?


A7: No, commits stay in history unless unreachable.

Q8: How to return to main after checking out an old commit?


A8: git checkout main

Q9: Why branching is useful?


A9: It allows independent development without affecting main code.

Q10: What is a commit hash?


A10: A unique ID representing a specific snapshot of the project.

Q11: Difference between -d and -D when deleting a branch?


A11: -d prevents deletion if unmerged; -D forces deletion.

Q12: What does git status show?


A12: Current branch, staged changes, unstaged changes, untracked files.

Q13: Purpose of .git folder?


A13: Stores all Git repository data and history.

Q14: Difference between git add . and git add filename?


A14: git add . stages all changes; git add filename stages only one file.

Q15: What does git log --oneline do?


A15: Shows commits in compact single-line format.

Q16: Can you commit in detached HEAD?


A16: Yes, but commits become orphaned unless you create a branch for them.

Q17: Difference between working directory, staging area, repository?


A17: Working directory = actual files; staging = changes prepared; repository = committed history.

Q18: Command to see changes before staging?


A18: git diff

Q19: Purpose of a commit message?


A19: It explains why changes were made; descriptive messages help maintain readability.

Q20: What happens if you try deleting the branch you're on?
A20: Git prevents it—you must switch to another branch first.

You might also like