Git & GitHub– Assignment- 1

Basic Questions

  1. Run a command to check your installed Git version. Paste the output.
  2. Configure Git with your global username as “developer101”. Show the command.
  3. Configure Git with your global email as “dev@example.com”. Show the command.
  4. Initialize a new Git repository inside a folder named myrepo. Show the command.
  5. Create a file hello.txt, write Hello Git! in it, and stage it. Which command will you use?
  6. Commit the staged file with the message “Initial commit”.
  7. Create another file notes.md, do not stage it, and then check the repo status. What is the output?
  8. Stage the file notes.md and commit it with the message “Added notes file”.
  9. Make changes in hello.txt, don’t stage them, and run git status. What does Git show?
  10. Run a command that shows commit history in detail.
  11. Run a command that shows commit history in one-line format.
  12. Add a third file app.js, commit it, and then show commit logs as a graph.
  13. Create a new branch named feature-login.
  14. Switch from the current branch to the new branch.
  15. Add changes in app.js, stage them, and commit in the feature-login branch.
  16. Run a command to view all branches in your repo.
  17. Run a command to check the difference between staged and unstaged changes.
  18. Display commit history of only the last 2 commits.
  19. Show commits authored by a specific username “developer101”.
  20. Delete the branch feature-login after switching back to main.

Intermediate Questions

  1. Initialize a repo in project1, add 2 files, and commit them. Show the sequence of commands.
  2. Edit one file in project1, run git status, and explain the output shown.
  3. Create a commit, then modify the same file, stage it again, and show how git diff –staged works.
  4. Initialize a repo and commit 3 files separately. Show only the commit IDs and messages in one-line format.
  5. Demonstrate how to configure a different username and email for only the current repo.
  6. Create a repo, add 2 files, commit them, then remove one file and show the commit history.
  7. Stage a file, then unstage it without deleting changes. Which command is used?
  8. Create a repo and show how to filter logs for commits containing the word “bugfix”.
  9. Initialize a repo, commit 3 times, and show how to display only the last commit details.
  10. Show the command to check untracked files in the repo.
  11. Add a file demo.txt, commit it, modify it, and show the difference between git log and git log –oneline.
  12. In a repo, create a branch test, commit 2 files in it, then switch back to main. Show all branches with commits.
  13. Show commit logs in graph format for the above repo.
  14. Run a command to view commit logs filtered by date (since=”yesterday”).
  15. Add a file, stage it, commit it, then change it but do not stage. Show the diff between working directory and last commit.
  16. Demonstrate the use of git show for a specific commit.
  17. Stage multiple files at once using a single command.
  18. Initialize a repo, make 2 commits, and show how to see commit history by a specific author.
  19. Show how git status output changes after staging vs before staging.
  20. Create a repo, add a file, commit it, then modify and commit again. Display logs as a graph to visualize history.

Advanced Questions

  1. Create a repo task-repo, add 3 commits, and display commit logs with oneline + graph combined.
  2. Make 4 commits in a repo, then display only the first commit using a single command.
  3. Initialize a repo, add 3 files, commit them, then edit 2 files. Show how to commit both together with one message.
  4. Create 2 branches dev and test, add different commits in both, then show logs with branch graphs.
  5. Initialize a repo, add 5 commits, and show only the last 3 commit IDs.
  6. Configure Git for repo-specific username/email, then check the configuration list.
  7. Stage a file, commit it, edit it again, and show how git diff behaves before and after staging.
  8. Create a repo, make 4 commits, then show commit history filtered by an author.
  9. Demonstrate git log –stat on a repo with 2 commits.
  10. Write the sequence of commands to: create repo → add 2 files → commit → create branch → commit in branch → view graph logs.