This are 5 most popular Git questions that you people ask on interview.
What is Git?
The first question is of course "What is Git", "Why do we need it?", "What problems it solves".
You need to say that Git is a version control system which means that it stores the snapshots of our files as a history and we can move between different states of our files. It also helps to different people in the team to work simultaneously on the project.
What is the difference between Git and Github
This is really popular question for beginner which directly show their level on understanding Git. So Git is a program, and Github is a service where we can store our project under Git control. Which means we can use Git locally without Github or with any other remote server.
How Gitflow is working
One question which is really good is "How Gitflow is working". It shows that people not only know the basic commands of Git but understands how work with Git can be organized in real projects and teams.
Gitflow is the most popular way to work with Git in teams. We normally have 2 branches master and develop. Master is super stable and mirrors production environment. Develop branch is used for current development process. It is normally less stable. When we want to implement new functionality we create a new feature branch from develop. After our functionality is ready we merge it back to develop branch. At the moment when the scope of our features is ready we create release branch from develop which should be tested before it is merged to master. If we have some bugs on production then we create a hotfix branch from master, fix bug and merge it back to both master and develop branch.
What is the difference between merge and rebase
What is the difference between merge and rebase? This is another nice question what shows your deep understanding of Git. When we want to merge a branch to other branch we can either use merge or rebase. Merge is more stable because it creates an additional merge commit. It means that merge stores the context of we we've done. Rebase on the other hand rewrites the history of our commits and doesn't store the context of what we've done because it just changes the order of the commit. This also means that you need to push with force because you rewrote the history. So the best way to merge branches is just to forget about rebase and use merge.
What is the difference between reverting and resetting
What is the difference between reverting and resetting. This is also a nice question because it shows if you know the typical Git commands and the differences between them. So reverting actually doesn't revert any changes. It figures out how to bring your files in a previous state by creating a new commit with inversion logic inside. So if you revert the last commit it will create new commit which removes all your changes inside.
Resetting on the other hand works differently. It just moves the pointer to other commit. The typical options to use it is soft and hard. If you use hard it will just discard all changes that were done after the commit where you moved to. If you use soft option it will put all changes that were done after the commit in non commited state. It makes sense to do so if you want to do additional changes to this files and commit them again.
Bonus: What is cherry-pick
And here is bonus question for you. What is cherry-pick and how it works? So cherry-pick command just takes a single commit and apply it on the top of current tree. It is a nice thing if you don't want to merge the whole branch but only take 1 commit for example. The most important thing to remember that cherry-pick doesn't copy commit. It creates the new commit with the same content.
So this were 5 must know git interview questions that I heard and asked really often.
Also if you want to improve your programming skill I have lots of full courses regarding different web technologies.