Friday, July 1, 2022

Top 10 Intermediate GIT Interview Question and Answer



*******************************************************

Top 10 Intermediate GIT Interview Questions

********************************************************


1. Why is it considered to be easy to work on Git? 
With the help of git, developers have gained many advantages in terms of performing the development process faster and in a more efficient manner. Some of the main features of git which has made it easier to work are:
  • Branching Capabilities:
-Due to its sophisticated branching capabilities, developers can easily work on multiple branches for the different features of the project.
- It also has an easier merge option along with an efficient work-flow feature diagram for tracking it.

  • Distributed manner of development: 
- Git is a distributed system and due to this nature, it became easier to trace and locate data if it's lost from the main server.
- In this system, the developer gets a repository file that is present on the server. Along with this file, a copy of this is also stored in the developer’s system which is called a local repository.
- Due to this, the scalability of the project gets drastically improved.

  • Pull requests feature: 
- This feature helps in easier interaction amongst the developers of a team to coordinate merge-operations.
- It keeps a proper track of the changes done by developers to the code.

  • Effective release cycle:

- Due to the presence of a wide variety of features, git helps to increase the speed of the release cycle and helps to improve the project workflow in an efficient manner.


2. How will you create a git repository?

  • Have git installed in your system. 
  • Then in order to create a git repository, create a folder for the project and then run git init . 
  • Doing this will create a .git file in the project folder which indicates that the repository has been created.  

 

3. Tell me something about git stash?
Git stash can be used in cases where we need to switch in between branches and at the same time not wanting to lose edits in the current branch. Running the git stash command basically pushes the current working directory state and index to the stack for future use and thereby providing a clean working directory for other tasks.


4. What is the command used to delete a branch?
  • To delete a branch we can simply use the command git branch –d [head]
  • To delete a branch locally, we can simply run the command: git branch -d <local_branch_name>  
  • To delete a branch remotely, run the command: git push origin --delete <local_branch_name> 
  • Deleting a branching scenario occurs for multiple reasons. One such reason is to get rid of the feature branches once it has been merged into the development branch.


5. What differentiates between the commands git remote and git clone?
git remote command creates an entry in   git config that specifies a name for a particular URL. Whereas git clone creates a new git repository by copying an existing one located at the URL. 



6. What does git stash apply command do?
  • git stash apply command is used for bringing the works back to the working directory from the stack where the changes were stashed using git stash command. 
  • This helps the developers to resume their work where they had last left their work before switching to other branch.


7. Differentiate between git pull and git fetch.
git pull -  This command pulls new changes from the currently working branch located in the remote central repository.
 git fetch -  This command is also used for a similar purpose but it follows a two step process: 
    1. Pulls all commits and changes from desired branch and stores them in a new branch of the local repository. current 
    2. For changes to be reflected in the current / target branch, git fetch should be followed by git merge command.

git pull = git fetch + git merge




8.  Can you give differences between “pull request” and “branch”?
pull request - This process is done when there is a need to put a developer’s change into another person’s code branch. 
branch - A branch is nothing but a separate version of the code. 



9. Why do we not call git “pull request” as “push request”?
“Push request” is termed so because it is done when the target repository requests us to push our changes to it. 
“Pull request” is named as such due to the fact that the repo requests the target repository to grab (or pull) the changes from it.




10. Can you tell the difference between Git and GitHub?
Git 
     - This is a distributed version control system installed on local machines which allow developers to
         keep track of commit histories and supports collaborative work.
    - This is maintained by “The Linux Foundation”.
    - SVN, Mercurial, etc are the competitors
GitHub 
    - This is a cloud based source code repository developed by using git. 
    - This was acquired by “Microsoft".
    - GitLab, Atlassian BitBucket, etc are the competitors.
    - GitHub provides a variety of services like forking, user management, etc along with providing a central repository for collaborative work.































No comments:

Post a Comment

How to install Java on EC2

***************************************** How to install Java on EC2 ***************************************** To be continued, In this post...

All Time Popular Post