Git & GitHub– Assignment- 1
Basic Questions
- Run a command to check your installed Git version. Paste the output.
- Configure Git with your global username as “developer101”. Show the command.
- Configure Git with your global email as “dev@example.com”. Show the command.
- Initialize a new Git repository inside a folder named myrepo. Show the command.
- Create a file hello.txt, write Hello Git! in it, and stage it. Which command will you use?
- Commit the staged file with the message “Initial commit”.
- Create another file notes.md, do not stage it, and then check the repo status. What is the output?
- Stage the file notes.md and commit it with the message “Added notes file”.
- Make changes in hello.txt, don’t stage them, and run git status. What does Git show?
- Run a command that shows commit history in detail.
- Run a command that shows commit history in one-line format.
- Add a third file app.js, commit it, and then show commit logs as a graph.
- Create a new branch named feature-login.
- Switch from the current branch to the new branch.
- Add changes in app.js, stage them, and commit in the feature-login branch.
- Run a command to view all branches in your repo.
- Run a command to check the difference between staged and unstaged changes.
- Display commit history of only the last 2 commits.
- Show commits authored by a specific username “developer101”.
- Delete the branch feature-login after switching back to main.
Intermediate Questions
- Initialize a repo in project1, add 2 files, and commit them. Show the sequence of commands.
- Edit one file in project1, run git status, and explain the output shown.
- Create a commit, then modify the same file, stage it again, and show how git diff –staged works.
- Initialize a repo and commit 3 files separately. Show only the commit IDs and messages in one-line format.
- Demonstrate how to configure a different username and email for only the current repo.
- Create a repo, add 2 files, commit them, then remove one file and show the commit history.
- Stage a file, then unstage it without deleting changes. Which command is used?
- Create a repo and show how to filter logs for commits containing the word “bugfix”.
- Initialize a repo, commit 3 times, and show how to display only the last commit details.
- Show the command to check untracked files in the repo.
- Add a file demo.txt, commit it, modify it, and show the difference between git log and git log –oneline.
- In a repo, create a branch test, commit 2 files in it, then switch back to main. Show all branches with commits.
- Show commit logs in graph format for the above repo.
- Run a command to view commit logs filtered by date (since=”yesterday”).
- Add a file, stage it, commit it, then change it but do not stage. Show the diff between working directory and last commit.
- Demonstrate the use of git show for a specific commit.
- Stage multiple files at once using a single command.
- Initialize a repo, make 2 commits, and show how to see commit history by a specific author.
- Show how git status output changes after staging vs before staging.
- Create a repo, add a file, commit it, then modify and commit again. Display logs as a graph to visualize history.
Advanced Questions
- Create a repo task-repo, add 3 commits, and display commit logs with oneline + graph combined.
- Make 4 commits in a repo, then display only the first commit using a single command.
- Initialize a repo, add 3 files, commit them, then edit 2 files. Show how to commit both together with one message.
- Create 2 branches dev and test, add different commits in both, then show logs with branch graphs.
- Initialize a repo, add 5 commits, and show only the last 3 commit IDs.
- Configure Git for repo-specific username/email, then check the configuration list.
- Stage a file, commit it, edit it again, and show how git diff behaves before and after staging.
- Create a repo, make 4 commits, then show commit history filtered by an author.
- Demonstrate git log –stat on a repo with 2 commits.
- Write the sequence of commands to: create repo → add 2 files → commit → create branch → commit in branch → view graph logs.