diff --git a/GIT_ASSIGNMENT.md b/GIT_ASSIGNMENT.md index 4721e94..01f4782 100644 --- a/GIT_ASSIGNMENT.md +++ b/GIT_ASSIGNMENT.md @@ -43,7 +43,8 @@ Assignment: Verify that a .git folder is created. Run git status and note the message (it should say “No commits yet”). - +----- +----- mkdir git-practice-Mag git init @@ -51,6 +52,235 @@ 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-<>, 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. +----- +----- +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 notes.txt commit, doesnt show up in the list + +git commit -m "Add first notes file" + +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. +------ +------ +cd git-practice-Mag + +touch todo.txt + +git add todo.txt stage + +git commit -m "List of tasks you need to complete" commit + +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 + + +echo "Task 1" >> todo.txt modify text +git add todo.txt +git commit -m "Add a task" commit changes + +Magdel@LAPTOP-NS5FVUS9 MINGW64 ~/git-practice-Mag (master) +$ git commit -m "Add new task" +[master b8c2503] Add new task + 1 file changed, 1 insertion(+) + + 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. +------ +------ +Magdel@LAPTOP-NS5FVUS9 MINGW64 ~/git-practice-Mag (master) +$ git log +commit b8c2503d1770ddf362d4862ec5f7095204d35015 (HEAD -> master) +Author: Magdel +Date: Sun Aug 17 21:01:52 2025 +0530 + + Add new task + +commit 3a3ab4dba4da1cab63238add554e247d6d7e9f38 +Author: Magdel +Date: Sun Aug 17 20:53:48 2025 +0530 + + List of tasks you need to complete + +commit 5287a291bc0e9cc6bcbf43e1d7199c9e0a2db3e0 +Author: Magdel +Date: Sun Aug 17 20:47:40 2025 +0530 + + Add first notes file + + +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 + + +echo "Task 2" >> todo.txt +git add todo.txt +git commit -m "Add task 2" + +Magdel@LAPTOP-NS5FVUS9 MINGW64 ~/git-practice-Mag (master) +$ git commit -m "Add task 2" +[master 82ca4b1] Add task 2 + 1 file changed, 1 insertion(+) + + + +git diff +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 + + git add todo.txt + git commit -m "New changes" + + Magdel@LAPTOP-NS5FVUS9 MINGW64 ~/git-practice-Mag (master) +$ git commit -m "New changes" +[master dc6ae86] New changes + 1 file changed, 2 insertions(+) + + git log --oneline + 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 + +git diff dc6ae86 82ca4b1 b8c2503 3a3ab4d 5287a29 + +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 + + +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 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +