Git Interview Question

What is git?

Git is a distributed versioning control system that keeps a track record of changes of our code base during a software development, suppose you are working in an organization and you are writing some code, so for managing a track record of changes git is used.

What is Version Control?

Version Control means the management of changes, it is not necessary that the versioning should be only for code. Versioning can be done for any kind of document, it could be a text file, an image or a video/audio.

What is Distributed Version Control?

Distributed version management is a sort of version management during which the whole codebase, as well as its full history, is reflected on each developer’s system. Suppose you are working in an organization as a developer on a very huge project, and there are some more developers working in the same project. So whatever changes will be done by you or some other developer those changes will be mirrored on each and every system of developers.

What is Staging?

Staging is a step or a process that comes before the commit step i.e. git commit. Actually git commit is performed in two steps: staging and actual commit. So as long as the changeset is in the staging area, git allows us to modify those changes according to our need and requirement which can include editing those changes or completely remove those changes based on our need.

What is Git Repository?

Git repository is just a file location that is hosted somewhere on cloud where you can store all the files related to your project.

What is Git Stash?

Git stash temporarily stashes(hideouts) or we can say hides the changes you’ve made to your working repository so you can work on something else, and then come back and re-apply them later on.

What are branches in git?

A branch is simply just a lightweight movable pointer to one of the commits.

How tag and branches are different from each other?

Both branches and tags are essentially just the pointers to commits. Difference between commit and tag is that commit is used to push staged changes into git repository and tag is used to freeze a commit to benchmark the branch.

What is Git remote?

The “git remote” command helps you to manage connections to remote repositories, git remote command is one piece of the broader system which is responsible for syncing changes.

Explain in brief various git operations?

The various git operations are as follows:-

  1. Initialize: It is used to convert an existing project to a Git repository or initialize a new, empty repository.
  2. Clone: Creating exact version of remote repository in local system environment
  3. Add: Add command, which adds changes in the working directory to the staging area
  4. Commit: Commit is used to save your changes to the local repository.
  5. Push: Push is used to upload local repository content to a remote repository.
  6. Pull: Pull command is used to update our local system repository with respect to our remote repository.
  7. Checkout: Checkout helps to switch between different branches
  8. Delete: Delete helps us to delete a particular branch or tag
  9. Tag:Tag is used in Git contexts for marking or freezing a specific version
  10. Stash: Git stash temporarily stashes the changes you’ve made to your working repository so you can work on something else, and then come back and re-apply them later on.
Subscribe Now