# Git Assignment ## 1. What is Git and Version Control What problem does Git solve? Git tracks changes in files (especially code) and helps multiple people collaborate without overwriting each other’s work. It lets you save versions, go back if something breaks, and merge changes safely. Real-life example: A school group project where everyone writes different parts of the same report. Git combines everyone’s edits into one final version without losing work. Why is Git better than emailing files? Emailing creates many confusing copies (e.g., report_final.docx, report_final2.docx). Git keeps a single version, records who changed what, and merges edits automatically, making collaboration easier and safer. ## Git Version Check ![Git version check](git_version.png) --- ## 2. Installing Git & Configuring User Info ![Git status](git_config.png) --- ## Git List ![Git status](git_config_list.png) --- ## 3. Initializing a Repository ## Git Init ![Git add](git_init.png) --- ## 4. Working Directory, Staging, and Commits ## Git Add ![Git add](git_add_new_file_in_local.png) ![Git add](git_file_staged.png) ![Git add](git_first_commit.png) ![Git add](git_status.png) --- ## 5. Adding & Committing Files ## Git Log ![Git log](git_log.png) --- ## 6. Viewing Commit Logs & Diffs ## Git Log (graph) ![Git log graph](git_oneline_log.png) --- ## Git Diff ![Git diff](git_diff.png) --- ## Git Diff (commit1 vs commit2) ![Git diff between two commits](git_compare_commit.png) --- ## 7. Creating & Switching Branches ## Git Branch ![Git branch](git_branch.png) ![Git new branch](git_branch_creation.png) ![Git checkout](git_branch_switching.png) --- ## 8. Cloning a Remote Repository ## Git Clone ![Git clone](git_clone.png) ![Git verified clone files](git_verify_clone_files.png) --- ## 9. Adding & Managing Remotes ## Git Remote ![Git Add & verify origin](git_add_remote_origin.png) --- ## 10. Pushing & Pulling Changes ## Git Pull ![Git files edited in repo](git_file_edited_in_repo.png) ![Git pull](git_pull_after_file_changed_repo.png) ![Git files verifed](git_verified_updates_after_pulll.png) ## Git Push ![Git push](git_push_in_main.png) --- ## 11. Ignoring Files with .gitignore ## .gitignore ![.gitignore](git_ignore_commit.png) ![.gitignore](git_ignore_status.png) --- ## Part 1: Viewing File History ## git log -- filename.extension ![.git log -- example.txt](git-log--.png) ## git log -p -- filename.extension ![git log -p](git_log_p_example.txt.png) ## git log --oneline -- filename.extension ![git log --oneline](git_log_oneline_example.txt.png) --- How many commits modified this file? 3 What differences do you see when adding the -p option? It describes what changed — which lines were added (+), which lines were removed (−) --- ## Part 2: Viewing File History with Blame ## git blame -- filename.extension ![.git blame -- assignment.txt](git_blame_example.txt.png) ## git blame -L 1,5 -- filename.extension ![git blame -L 1,5](git_blame_L_1_5_example.png) ## git blame -e -- filename.extension ![git blame -e](git_blame_e_example.png) --- Who changed each line of the file? Arjun,Renejit, Arjun, Arjun ec0f5f8e (Arjun G 2025-09-10 23:41:01 +0530 1) Tech Thursday assignment 3 updated ae37ccf5 (Renejit 2025-09-10 16:29:53 +0530 2) date 10-09-2025 f97b76b3 (Arjun G 2025-09-11 00:00:58 +0530 3) wednesday dc7fc330 (Arjun G 2025-09-11 00:01:50 +0530 4) Practise session extended to Thursday How does -L help when the file is large? Limits the blame output to just a range of lines when the file is large. What extra information does -e provide? Author email --- ## Part 3: Merging Branches ## git checkout -b feature/feature-1 ![git checkout -b feature/feature-1](git_checkout_feature_blame.png) ## git merge feature/feature-1 ![git merge feature/feature-1](git_merge_main.png) ## git log --graph --oneline --all ![git log --graph --oneline --all](git_log_after_merge.png) --- Did Git perform a fast-forward merge or a 3-way merge? 3 way merge What does git log --graph --oneline --all show after the merge? shows a merge commit (06f4ad1) at the top. The graph shows two diverging branches (main & feature/feature-1) and how they were joined together. main now contains all changes from both histories.