• DevOps CourseExplore
  • git quiz day 3

    Last Updated :
    Discuss
    Comments

    Question 1

    You accidentally committed a secret file config.env. How do you stop tracking it but keep it locally?

    • A

      Delete the file and re-create it

    • B

      Add it to .gitignore only

    • C

      Use git rm --cached config.env and commit

    • D

      Run git reset HEAD config.env

    Question 2

    After cloning a bare repository, you see the warning “cloned an empty repository”. What should you do next?

    • A

      Create a branch in the bare repo

    • B

      Make a commit locally and push it

    • C

      Run git pull to fetch code

    • D

      Initialize git init again

    Question 3

    What happens if you push directly to a non-bare repository on a shared server?


    • A

      Git overwrites the files silently

    • B

      Push is merged automatically

    • C

      Push is rejected with an error

    • D

      Repository converts to bare

    Question 4

    You want to restore the project to a specific past commit using its hash. Which command works?


    • A

      git reset --merge

    • B

      git checkout

    • C

      git revert

    • D

      git status

    Question 5

    You made a commit but forgot one file. How can you include it in the same commit?

    • A

      git commit --fix

    • B

      git add file && git commit --amend

    • C

      git update && git commit

    • D

      git merge HEAD

    Question 6

    You want to see new commits from the remote without merging them into your branch. Which command should you use?

    • A

      git pull

    • B

      git fetch

    • C

      git merge

    • D

      git reset

    Question 7

    In .gitignore, how do you ignore all .log files in logs/ except important.log?

    • A

      logs/*.log then !logs/important.log

    • B

      *.log only

    • C

      logs/** and important.log

    • D

      logs/ then !*.log

    Question 8

    What is the purpose of git push -u origin main compared to git push origin main?


    • A

      Deletes local commits after push

    • B

      Creates remote branch only

    • C

      Sets upstream tracking for future commands

    • D

      Ignores tags during push

    Question 9

    Which command shows who last modified each line in a file?


    • A

      git log file.txt

    • B

      git blame file.txt

    • C

      git history file.txt

    • D

      git status file.txt

    Question 10

    Which Markdown feature allows checklists in a README?


    • A

      Code blocks using backticks

    • B

      Blockquotes with >

    • C

      Task lists using - [ ] and - [x]

    • D

      Tables with | and -

    Tags:

    There are 10 questions to complete.

    Take a part in the ongoing discussion