Basic knowledge
Internal question bank of Java training class, relevant materials for 2023 Git branch management interview questions
Java training course internal question bank, related materials for 2023 Git branch management interview questions. Free sharing, come and take a look, regret for missing ten thousand years.
1. What is Git?
I suggest that you first understand the architecture of Git before answering this question, as shown in the following figure. Try to explain this figure: Algorithm
Git is a Distributed Version Control System (DVCS). It can track changes to files and allow you to revert to any specific version of the changes.
Compared to other version control systems (VCS) such as SVN, its distributed architecture has many advantages, one of which is that it does not rely on a central server to store all versions of project files.
Every developer can "clone" a copy of the repository I marked with "Local repository" in the diagram, and have a complete history of the project on their hard drive. Therefore, when the server is interrupted, all the recovery data you need is in your teammates' local Git repository.
There is also a central cloud storage to which developers can submit changes and share them with other team members. As shown in the figure, all collaborators are submitting changes to the "remote repository".
What are the commands submitted in Git?
The answer is very simple.
The command used for writing submissions is git commit - a. bash
Now let's explain the - a flag. After adding - a on the command line, it instructs Git to submit the new content of all modified tracked files. Also, if you need to submit a new file for the first time, you can git add it before git commit - a. The server
3. What is a "bare repository" in Git?
You should explain the difference between "work directory" and "bare repository". WeChat
The "bare" repository in Git only contains version control information without work files (no work tree), and it does not contain special. git subdirectories. On the contrary, it directly contains all the contents of the. git subdirectory in the main directory, where the work directory includes: multithreading
A. git subdirectory that contains all relevant Git revision history records for your warehouse.
A copy of the work tree or checked out project file.
4. What language is Git written in?
You need to explain the reason for using it, not just the name of the language. I suggest you answer this way:
Git is written in C language. GIT is fast, and C language achieves this by reducing runtime overhead.
5. In Git, how do you restore submissions that have already been pushed and made public?
There can be two answers to this question and make sure that you include both because any of the below options can be used depending on the situation: 1
There can be two answers to this question, and you should also include these two answers when answering, as the following options can be used depending on the specific situation:
Delete or fix the error files in the new submission and push them to the remote repository. This is the most natural way to fix errors. After making necessary modifications to the file, submit it to the remote repository I will use
git commit -m "commit message"
Create a new submission and undo all changes made in the error submission. The following commands can be used:
git revert <name of bad commit>
What is the difference between git pull and git fetch?
The git pull command extracts new changes or commits for a specific branch from the central repository and updates the target branch in the local repository.
Git fetch is also used for the same purpose, but its working method is slightly different. When you execute a git fetch, it will extract all new submissions from the required branches and store them in a new branch in the local repository. If you want to reflect these changes in the target branch, you must execute a git merge after the git fetch. The target branch will only be updated after merging the target branch and the obtained branch. For convenience, please remember the following equation:
git pull = git fetch + git merge
What is the 'staging area' or 'index' in git?
For this answer try to explain the below diagram as you can see:
Can be explained through the following figure:
Before completing the submission, it can be formatted and reviewed in an intermediate area called "staging area" or "index". From the figure, it can be seen that each change is first validated in the staging area, which I refer to as the "stage file", and then submitted to the repository.
8. What is a git stash?
Firstly, the necessity of git stash should be explained.
In general, when you have been working on a certain part of the project, if you want to switch branches at a certain time to handle other things, things will be in a chaotic state. The problem is, you don't want to submit half of the completed work so that you can return to your current job later. The answer to this problem is git stash.
Explain again what git stash is.
Stash will save your work directory, modified tracking files, and temporary changes in a pile of unfinished changes, allowing you to reapply these changes at any time.
9. What is a git stash drop?
After explaining the purpose of using git stash drop to answer this question.
The git stash drop command is used to delete hidden items. By default, it will delete the last added storage item, and if parameters are provided, it can also delete specific items.
Here is an example.
To remove a specific storage item from the hidden item list, use the following command:
Git stash list: It will display a list of hidden items, such as:
stash@{0}: WIP on master: 049d078 added the index file
stash@{1}: WIP on master: c264051 Revert “added file_size”
stash@{2}: WIP on master: 21d80a5 added number to log
If you want to delete a project named stach @ {0}, use the command git stach drop stach @ {0}.
The above is the relevant information for the 2023 Git branch management interview question. Can you answer it? If you want to learn more about Java interview questions, you can follow the Java official website of the Power Node.