Add GIT_ASSIGNMENT.md

This commit is contained in:
2025-08-19 08:48:23 +00:00
commit 6af3bae97c

352
GIT_ASSIGNMENT.md Normal file
View File

@ -0,0 +1,352 @@
# 1. What is Git and Version Control
Assignment:
-Write down (in your own words) what problem Git solves.
-Find one real-life example where multiple people edit the same file (school project, code, Google Docs).
-Answer: Why is version control better than emailing files back and forth?
---
Git is mainly created to keep (1)control of version history especially during development - it makes sure nothing is lost due to human error and helps keep track of changes and by who. This is important to (2)ensure efficiency during any project - takes up lesser time to fix errors and go back and forth between versions if necessary. Files are also (3)accessible remotely and doesn't require a specific device.
Examples: Group projects presentations, research papers worked on by multiple people
Emailing back and forth takes a lot of disk space and memory as opposed too version control that keeps track of specific changes and times. Emailing back and forth requires manual intervention to keep track of version, prone to error and confusion, sometimes data could get lost in the pile. Git is not managed by a singular person, which makes sure all files are accounted for and treated the same - makes it easier to look back and understand the process each version or file went through because they all underwent the same set of file managment rules.
# 2. Installing Git & Configuring User Info(COMPLETED)
Assignment:
Install Git (if not already installed).
Run:
git --version
git config --global user.name "Your Name"
git config --global user.email "your@email.com"
Verify with:
git config --list
### My Results
```
user.name=Magdel
user.email=raokhshna.m@comorin.co
```
# 3. Initializing a Repository
Assignment:
Create a new folder git-practice-<<your_name>>.
Inside, run:
git init
Verify that a .git folder is created.
Run git status and note the message (it should say “No commits yet”).
### My work
`mkdir git-practice-Mag`
`git init `
`ls -a`
verify folder
`git status`
nothing added to commit but untracked files present (use "git add" to track)
# 4. Working Directory, Staging, and Commits
Assignment:
In git-practice-<<your_name>>, create a file notes.txt.
Run:
git status
Observe which area (untracked → staged → committed) the file is in as you do:
git add notes.txt
git commit -m "Add first notes file"
git status
Write down how the status changed after each command.
### My work
`cd git-practice-Mag` go to Directory
`touch notes.txt ` creates file
`git status` notes.txt in the list of yet to be commit
`git add notes.txt`
`git status`
`git commit -m "Add first notes file"`
#### Result
```
Magdel@LAPTOP-NS5FVUS9 MINGW64 ~ (master)
$ git commit -m "Add first notes file"
[master (root-commit) 5287a29] Add first notes file
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 notes.txt
```
`git status`
# 5. Adding & Committing Files
Assignment:
Add another file todo.txt.
Stage and commit with a meaningful message.
Modify todo.txt, then commit the change again.
Run git log --oneline to see both commits.
### My work
`cd git-practice-Mag`
`touch todo.txt`
`git add todo.txt` stage
`git commit -m "List of tasks you need to complete"` commit
#### Result
```
Magdel@LAPTOP-NS5FVUS9 MINGW64 ~/git-practice-Mag (master)
$ git commit -m "List of tasks you need to complete"
[master 3a3ab4d] List of tasks you need to complete
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 git-practice-Mag/todo.txt
```
### My work
echo "Task 1" >> todo.txt modify text
git add todo.txt
git commit -m "Add a task" commit changes
#### Result
```
Magdel@LAPTOP-NS5FVUS9 MINGW64 ~/git-practice-Mag (master)
$ git commit -m "Add new task"
[master b8c2503] Add new task
1 file changed, 1 insertion(+)
```
### My Work
`git log --oneline`
#### Result
```
git log --oneline Magdel@LAPTOP-NS5FVUS9 MINGW64 ~/git-practice-Mag (master)
$ git log --oneline
b8c2503 (HEAD -> master) Add new task
3a3ab4d List of tasks you need to complete
5287a29 Add first notes file
```
# 6. Viewing Commit Logs & Diffs
Assignment:
Run:
git log
git log --oneline --graph
git diff
Edit notes.txt and check the changes with git diff before staging.
Stage and commit, then run git diff commit1 commit2 to see what changed between commits.
### My work
`git log`
#### Result
```
Magdel@LAPTOP-NS5FVUS9 MINGW64 ~/git-practice-Mag (master)
$ git log
commit b8c2503d1770ddf362d4862ec5f7095204d35015 (HEAD -> master)
Author: Magdel <raokhshna.m@comorin.co>
Date: Sun Aug 17 21:01:52 2025 +0530
Add new task
commit 3a3ab4dba4da1cab63238add554e247d6d7e9f38
Author: Magdel <raokhshna.m@comorin.co>
Date: Sun Aug 17 20:53:48 2025 +0530
List of tasks you need to complete
commit 5287a291bc0e9cc6bcbf43e1d7199c9e0a2db3e0
Author: Magdel <raokhshna.m@comorin.co>
Date: Sun Aug 17 20:47:40 2025 +0530
Add first notes file
```
### My work
`git log --oneline --graph`
#### Result
```
Magdel@LAPTOP-NS5FVUS9 MINGW64 ~/git-practice-Mag (master)
$ git log --oneline --graph
* b8c2503 (HEAD -> master) Add new task
* 3a3ab4d List of tasks you need to complete
* 5287a29 Add first notes file
```
### My work
`echo "Task 2" >> todo.txt`
`git add todo.txt`
`git commit -m "Add task 2"`
#### Result
```
Magdel@LAPTOP-NS5FVUS9 MINGW64 ~/git-practice-Mag (master)
$ git commit -m "Add task 2"
[master 82ca4b1] Add task 2
1 file changed, 1 insertion(+)
```
### My work
`git diff`
#### Result
```
Magdel@LAPTOP-NS5FVUS9 MINGW64 ~/git-practice-Mag (master)
$ git diff
warning: in the working copy of 'git-practice-Mag/todo.txt', LF will be replaced by CRLF the next time Git touches it
diff --git a/git-practice-Mag/todo.txt b/git-practice-Mag/todo.txt
index b4f858d..5a4b868 100644
--- a/git-practice-Mag/todo.txt
+++ b/git-practice-Mag/todo.txt
@@ -1,3 +1,4 @@
Task 1
Task 2
```
### My work
`git add todo.txt`
`git commit -m "New changes"`
#### Result
```
Magdel@LAPTOP-NS5FVUS9 MINGW64 ~/git-practice-Mag (master)
$ git commit -m "New changes"
[master dc6ae86] New changes
1 file changed, 2 insertions(+)
```
### My Work
`git log --oneline`
#### Result
```
Magdel@LAPTOP-NS5FVUS9 MINGW64 ~/git-practice-Mag (master)
$ git log --oneline
dc6ae86 (HEAD -> master) New changes
82ca4b1 Add task 2
b8c2503 Add new task
3a3ab4d List of tasks you need to complete
5287a29 Add first notes file
```
### My Work
`git diff dc6ae86 82ca4b1 `
#### Result
```
Magdel@LAPTOP-NS5FVUS9 MINGW64 ~/git-practice-Mag (master)
$ git diff dc6ae86 82ca4b1
diff --git a/git-practice-Mag/todo.txt b/git-practice-Mag/todo.txt
index 5a4b868..9d31ec7 100644
--- a/git-practice-Mag/todo.txt
+++ b/git-practice-Mag/todo.txt
@@ -1,4 +1,2 @@
Task 1
Task 2
```
### My Work
`git diff dc6ae86 5287a29`
#### Result
```
Magdel@LAPTOP-NS5FVUS9 MINGW64 ~/git-practice-Mag (master)
$ git diff dc6ae86 5287a29
diff --git a/git-practice-Mag/todo.txt b/git-practice-Mag/todo.txt
deleted file mode 100644
index 5a4b868..0000000
--- a/git-practice-Mag/todo.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-Task 1
-Task 2
-Task 2
-Task 3
```