Git & GitHub– Assignment– 5

Baics Questions

  1. Create a .gitignore file to ignore all .env files in a repo.
  2. Add rule in .gitignore to ignore the node_modules folder.
  3. Test by creating a file secrets.txt and ensure it is ignored by Git.
  4. Show command to check which .gitignore rule is affecting a file.
  5. Remove a tracked file config.json from repo but keep it locally.
  6. Add .gitignore rule to ignore all .log files in any subfolder.
  7. Add .gitignore entry to ignore only debug.log but not error.log.
  8. Create a commit signed with GPG key.
  9. Verify if the last commit is GPG signed.
  10. List all GPG keys configured in Git.
  11. Configure Git to sign all commits by default.
  12. Protect main branch in GitHub so that force-push is not allowed.
  13. Enable branch protection rule requiring PR reviews before merging.
  14. Create rule to require status checks before merging into main.
  15. Create branch secure-feature, push it, and mark as protected.
  16. Run command to restore a deleted file index.html using git restore.
  17. Use git restore to discard changes from staging area for test.js.
  18. Switch from branch dev to feature-x using git switch.
  19. Create a new branch docs-update directly using git switch -c.
  20. Show command to list files tracked by Git LFS in a repo. 

Intermediate Questions

  1. Initialize Git LFS and track all .png files.
  2. Untrack .png files from Git LFS but keep them in repo history.
  3. Upload large file video.mp4 using Git LFS.
  4. Show command to fetch Git LFS objects for a cloned repo.
  5. Simulate: Create commit with secret key, then remove it from history using git filter-repo.
  6. Encrypt file credentials.txt before committing it.
  7. Decrypt file credentials.txt.gpg after pulling from repo.
  8. Sign a commit with a different GPG key than global one.
  9. Verify signature of commit abc123 explicitly.
  10. Configure repo to reject unsigned commits.
  11. Create Codespace for repo sample-repo from CLI.
  12. Install extension in Codespace via CLI.
  13. Run command to rebuild a GitHub Codespace environment.
  14. Open Codespace for branch dev directly from CLI.
  15. Enable GitHub Copilot for current repo.
  16. Show command to check if Copilot is enabled for your account.
  17. Write commit message suggestion using GitHub Copilot.
  18. Use Copilot CLI to generate a code snippet in Python.
  19. Run GitHub Action workflow manually from CLI.
  20. View logs of last failed GitHub Action workflow.

Advanced Questions

  1. Create a repo, configure Git LFS for .zip files, push file backup.zip, and verify in GitHub.
  2. Simulate: Commit secret accidentally, remove it completely from history, force-push clean repo.
  3. Sign last 3 commits with GPG using git rebase –exec.
  4. Create branch protection rule that requires 2 reviewers and signed commits.
  5. Create issue “Enable Copilot”, then write commit using Copilot suggestion linked to issue.
  6. Simulate: Push 2GB file without LFS, get error, fix it using Git LFS, and push again.
  7. Run command to restore both staged and unstaged changes in one step.
  8. Create Codespace, install Node.js, run project, and commit directly from Codespace.
  9. Simulate: Switch to wrong branch using git switch, fix it by switching back, and merge safely.
  10. Write sequence: track .psd via LFS → push to remote → clone on another machine → pull LFS object.