Q.1 – How to Compute object ID and optionally creates a blob from a file?
- git hash-object
- git cat-file
- git update-ref
- git count-objects
Answer – 1. git hash-object
Q.2 – How to Update the object name stored in a ref safely?
- git hash-object
- git cat-file
- git update-ref
- git count-objects
Answer – 3. git update-ref
Q.3 – Which commands will Reference logs or record when the tips of branches and other references were updated in the local repository.
- git log
- git reflog
- git update-ref
- git count-objects
Answer – 2. git reflog
Q.4 – git stores different types of objects in .git/objects. Which is wrong objecst type?
- commit
- tree
- blob
- parent
Answer – 4. parent
Q.5 – How to show the contents of the hashed files in .git/objects?
- git show
- git reflog
- git log
- git cat-file
Answer – 4. git cat-file
Q. 6 – How to shows us the type of the object represented by a particular hash?
- git cat-file -t
- git cat-file -p
- git cat-file -k
- git cat-file -type
Answer – 1. git cat-file -t
Q. 7 – How does “git rebase” move an existing commit?
- It just changes the parent in the commit file.
- It changes the commit’s parent and its SHA1.
- None of these
- It copies over the commit to a new commit with a different parent and SHA1.
Answer – 4. It copies over the commit to a new commit with a different parent and SHA1.
Q. 8 – What happens to unreachable objects in the database?
- They immediately get deleted.
- You can never make an object unreachable in Git.
- They stay there forever, in case you want to retrieve them.
- They can eventually get garbage-collected.
Answer – 4. They can eventually get garbage-collected.
Q. 9 – What’s a “pull”?
- A “merge” followed by a “push”
- A “push” followed by a “merge”
- A “fetch” followed by a “push”
- A “fetch” followed by a “merge”
Answer – 4. A “fetch” followed by a “merge”
Q. 10 – Can an object in Git be safely modified?
- No: you might get the same SHA1 as another object.
- No: if you changed even one bit, then you’d get a different object with its own SHA1.
- Yes: you can edit the content of the file that stores the object.
- Yes: you can ask Git to generate a new SHA1 for the object.
Answer – 2. No: if you changed even one bit, then you’d get a different object with its own SHA1.
Q. 11 – What are the four types of objects in the Git database?
- Blobs, Trees, Commits and Versions
- Files, Directories, Commits and Tags
- Blobs, Trees, Commits and Annotated Tags
- Blobs, Trees, Commits and Branches
Answer – 3. Blobs, Trees, Commits and Annotated Tags
Q. 12 – What happens when you commit?
- The current branch changes, HEAD doesn’t.
- HEAD changes, the current branch doesn’t.
- Neither HEAD nor the current branch change.
- Both HEAD and the current branch change.
Answer – 1. The current branch changes, HEAD doesn’t.
Q. 13 – Which objects are created when you merge?
- Zero or one commit and nothing else
- Merges don’t create new objects.
- Zero or one commit, and possibly new trees and blobs
- Exactly one commit and nothing else
Answer – 3. Zero or one commit, and possibly new trees and blobs
Q. 14 – Where can HEAD point?
- To a branch, a commit, a tree, or a blob
- To a branch
- To a branch or a commit
- To a branch or nowhere
Answer – 3. To a branch or a commit
Q. 15 – Which of these is not a Git command?
- git clone
- git fork
- git push
- git fetch
Answer – 2. git fork