GIT INTERVIEW QUESTIONS (PART-1)

Share via:
GIT INTERVIEW QUESTIONS

Dear Readers,

In this article, we will discuss GIT INTERVIEW QUESTIONS. 

Frequently  GIT Questions
1.what is the difference between distributed version control system vs centralized version control system ?

Ans.

1. Both the systems works with the server and client relationship.In central version control,server contains all the history of the source code whereas in distributed version control both the server and the client maintains the history of source code.

2.In CVS,client cannot have the copy of source code. In DVS clients will be having the copy of the code which is easy to work in the offline too.

3.CVS is very easy to learn and set up,where as DVS is difficult to learn which involves in remembering of multiples commands like merge and etc.

4. In CVS,client has to be in touch with the server for any latest information, this process may slow the communication speed. In DVS, client will have the copy of the source code. There is not need of communication with the server all the time.

5.Copying the source code offline will greatly help you while the DVS server is down. If CVS server is down there is not changes of work.

2. what is git branching strategy ? or talk about git branching strategy best practices

Ans. Most popular DVCS like GIT gives us more flexibility, how to share and managing the code.The branching strategy is the most and powerful techniques that is avaialble with the git.

GIt branching strategies:

1. keeping the branch simple by maintaining the sperate branches for the features and bug fixes, updating the main branch up-to-date.
2. Naming the feature branches name by following particular conventions like “ktexperts/questions/description”
3. Usage of flags for a long running branches.

 

3. Types of version control systems

Ans.
1.Local version control systems: Its a version control systems in the local machines, which is a common method followed by us in our daily purposes. Example: updating the files for serveral times. This will have a higher probability of accidentally writing to the other files.
2.Centralized version control systems : Works on a client-server relationship. server contains the history of the complete source code where clients check the information from the central server
3.Distributed control systems : this is an updated version of CVCS, both the server and client will have an complete history and clients can save the source code offline, complexity in understanding and usage compared to CVCS is little higher.

 

4.what is process or list all the steps to commit the multiple git commits into single git commit message on a branch ?

Ans. step 1: Once your branch with multiple git commit, use the command: “git rebase -i HEAD~n
where i is for interactive mode and n is for number of commits that you have committed in that branch.
step 2: After running that command, a file will be opening with all the commits that you have. Replace the “pick” keyword with “squash”, this will squash all the commits into the first commit.
step 3: check the log of the branch by using the command “git log”. Now you can see all the commits you squashed under the single commit which you wished(In my case first commit)

 

5. what is git merge ? what are the steps need to be followed to merge two git branches ?
Ans. Git merge is used to combine 2 branches.
steps to be followed:

1. let feature1 be the branch of the master with the commits(f1(first commit), f2(latest commit))
2. check out to the master by using the command: git checkout master
3. now apply merge on the feature 1 using the command: git merge feature1
4. In order not to complain about the git branch about the feature1 is now accessed by the master branch. command: git branch -d feature1

 

6.what is command to create a branch ?
Ans. Being in the master , create a branch using the command “git checkout -b branch-name”

 

7.what is git rebase ?
Ans: git rebase is used to move the base of the feature branch to master branch’s ending point.

 

8. what is git we-hooks ?
Ans: git hooks are the scripts that are used to execute before or after the events like commit,push,and recieve.Example git hooks can be found “https://www.git-scm.com/docs/githooks#_pre_push”

 

9. what is the difference between git pull vs git push vs git fetch ?
Ans. Git fetch : This command is used to fetch the information related to any updates from the original to the local.No file transfer’s occurs ,just an info whether is a changes or not.
Git pull : By using this command,updates are fetched from the original to the local git and copies the data or files to the local machine.
Git push: This command is used to push the files which are commited in the local Git to remote Git.

 

10. what is git squash ? how to squash the last N commits into single commit ?
Ans.  git squash is a techniques which helps you to breakdown multiple series of commits to fewer number of commits or single commit.

how to squash the last N commits into single commit ?

Step 1: Once your branch with multiple git commit, use the command: “git rebase -i HEAD~n
where i is for interactive mode and n is for number of commits that you have committed in that branch.
Step 2: After running that command, a file will be opening with all the commits that you have. Replace the “pick” keyword with “squash”, this will squash all the commits into the first commit.
Step 3: check the log of the branch by using the command “git log”. Now you can see all the commits you squashed under the single commit which you wished(In my case first commit).

 

 

Thank you for giving your valuable time to read the above information. Please click here to subscribe for further updates

KTEXPERTS is always active on below social media platforms.

 

Facebook : https://www.facebook.com/ktexperts/
LinkedIn   : https://www.linkedin.com/company/ktexperts/
Twitter     : https://twitter.com/ktexpertsadmin
YouTube : https://www.youtube.com/c/ktexperts
Instagram : https://www.instagram.com/knowledgesharingplatform

Share via:
Note: Please test scripts in Non Prod before trying in Production.
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Add Comment