Git & GitHub– Assignment– 5
Baics Questions
- Create a .gitignore file to ignore all .env files in a repo.
- Add rule in .gitignore to ignore the node_modules folder.
- Test by creating a file secrets.txt and ensure it is ignored by Git.
- Show command to check which .gitignore rule is affecting a file.
- Remove a tracked file config.json from repo but keep it locally.
- Add .gitignore rule to ignore all .log files in any subfolder.
- Add .gitignore entry to ignore only debug.log but not error.log.
- Create a commit signed with GPG key.
- Verify if the last commit is GPG signed.
- List all GPG keys configured in Git.
- Configure Git to sign all commits by default.
- Protect main branch in GitHub so that force-push is not allowed.
- Enable branch protection rule requiring PR reviews before merging.
- Create rule to require status checks before merging into main.
- Create branch secure-feature, push it, and mark as protected.
- Run command to restore a deleted file index.html using git restore.
- Use git restore to discard changes from staging area for test.js.
- Switch from branch dev to feature-x using git switch.
- Create a new branch docs-update directly using git switch -c.
- Show command to list files tracked by Git LFS in a repo.
Intermediate Questions
- Initialize Git LFS and track all .png files.
- Untrack .png files from Git LFS but keep them in repo history.
- Upload large file video.mp4 using Git LFS.
- Show command to fetch Git LFS objects for a cloned repo.
- Simulate: Create commit with secret key, then remove it from history using git filter-repo.
- Encrypt file credentials.txt before committing it.
- Decrypt file credentials.txt.gpg after pulling from repo.
- Sign a commit with a different GPG key than global one.
- Verify signature of commit abc123 explicitly.
- Configure repo to reject unsigned commits.
- Create Codespace for repo sample-repo from CLI.
- Install extension in Codespace via CLI.
- Run command to rebuild a GitHub Codespace environment.
- Open Codespace for branch dev directly from CLI.
- Enable GitHub Copilot for current repo.
- Show command to check if Copilot is enabled for your account.
- Write commit message suggestion using GitHub Copilot.
- Use Copilot CLI to generate a code snippet in Python.
- Run GitHub Action workflow manually from CLI.
- View logs of last failed GitHub Action workflow.
Advanced Questions
- Create a repo, configure Git LFS for .zip files, push file backup.zip, and verify in GitHub.
- Simulate: Commit secret accidentally, remove it completely from history, force-push clean repo.
- Sign last 3 commits with GPG using git rebase –exec.
- Create branch protection rule that requires 2 reviewers and signed commits.
- Create issue “Enable Copilot”, then write commit using Copilot suggestion linked to issue.
- Simulate: Push 2GB file without LFS, get error, fix it using Git LFS, and push again.
- Run command to restore both staged and unstaged changes in one step.
- Create Codespace, install Node.js, run project, and commit directly from Codespace.
- Simulate: Switch to wrong branch using git switch, fix it by switching back, and merge safely.
- Write sequence: track .psd via LFS → push to remote → clone on another machine → pull LFS object.