MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

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)

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

Git Tutorial: Git Index

The Git index, also called the staging area or cache, is the binary file .git/index. It records exactly what your next commit will contain: each tracked path…

Read More

Git Lab Exercise & Assignment: Git cherry-pick: Part – 12

git cherry-pick copies one or more existing commits from another branch and applies them as new commits on your current branch. This lab corrects and completes the…

Read More

Git Lab Exercise & Assignment: Git remote branching and github: Part – 7

In this paired lab exercise, two people share changes through GitHub. One creates a repository, the other forks it, and each one fetches, compares and merges the…

Read More

Git Lab Exercise & Assignment: Branching & Merging & Conflicts: Part – 4

This lab has you create a merge conflict on purpose: two branches change the same line of one file, and you then inspect the conflict, look at…

Read More

Git Lab Exercise & Assignment: Changing History with Amend: Part – 5

This lab covers three ways to rewrite local Git history: fixing the last commit with git commit –amend, reordering commits with git rebase -i, and undoing it…

Read More

Git Lab Exercise & Assignment: Working with Local Branch: Part – 3

This lab shows the local branch lifecycle in Git: create a branch, commit on it, commit separately on master so the two diverge, try to delete the…

Read More