Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

Git Interview Questions and Answer Part – 7

How to Compute object ID and optionally creates a blob from a file?

  • git hash-object (Ans)
  • git cat-file
  • git update-ref
  • git count-objects

How to Update the object name stored in a ref safely?

  • git hash-object
  • git cat-file
  • git update-ref (Ans)
  • git count-objects

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 (Ans)
  • git update-ref
  • git count-objects

git stores different types of objects in .git/objects. Which is wrong objecst type?

  • commit
  • tree
  • blob
  • parent (Ans)

How to show the contents of the hashed files in .git/objects?

  • git show
  • git reflog
  • git log
  • git cat-file (Ans)

How to shows us the type of the object represented by a particular hash?

  • git cat-file -t (Ans)
  • git cat-file -p
  • git cat-file -k
  • git cat-file -type

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 SHA-
  • None of these
  • It copies over the commit to a new commit with a different parent and SHA- (Ans)

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-collecte- (Ans)

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” (Ans)

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 SHA- (Ans)
  • 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.

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 (Ans)
  • Blobs, Trees, Commits and Branches

What happens when you commit?

  • The current branch changes, HEAD doesn’t. (Ans)
  • HEAD changes, the current branch doesn’t.
  • Neither HEAD nor the current branch change.
  • Both HEAD and the current branch change.

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 (Ans)
  • Exactly one commit and nothing else

Where can HEAD point?

  • To a branch, a commit, a tree, or a blob
  • To a branch
  • To a branch or a commit (Ans)
  • To a branch or nowhere

Which of these is not a Git command?

  • git clone
  • git fork (Ans)
  • git push
  • git fetch

Which objects in Git have a SHA1 hash?

  • Only Blobs and Trees
  • Each object in the database (Ans)
  • Each object in the database, and the same object can have multiple SHA1 hashes
  • Only Commits

Can an object in Git be safely modified?

  • No: if you changed even one bit, then you’d get a different object with its own SHA1. (Ans)
  • 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.
  • No: you might get the same SHA1 as another object

Where does Git store the names of files and directories?

  • In the object database, inside the trees that point to the objects (Ans)
  • In the object database, inside the blobs and trees that store files and directories
  • Nowhere
  • In the “.git/links” subdirectory

What happens when you commit?

  • Both HEAD and the current branch change.
  • Neither HEAD nor the current branch change.
  • HEAD changes, the current branch doesn’t.
  • The current branch changes, HEAD doesn’t. (Ans)

Which objects are created when you merge?

  • Merges don’t create new objects.
  • Exactly one commit and nothing else
  • Zero or one commit and nothing else
  • Zero or one commit, and possibly new trees and blobs (Ans)
Rajesh Kumar
Follow me
Latest posts by Rajesh Kumar (see all)