Git
General 7 questions
- #1How to list the current git references in a given repository?
- #2What git diff does?
- #3Which one is faster? git diff-index HEAD or git diff HEAD
- #4By which other Git commands does git diff used?
- #5Describe how
git statusworks - #6If git status has to run diff on all the files in the HEAD commit to those in staging area/index and another one on staging area/index and working directory, how is it fairly fast?
- #7Git - Squashing Commits
Objective
Learn how to squash commits
Instructions
- In a git repository, create a new file with the content "Mario" and create a new commit
- Make change to the content of the file you just created so the content is "Mario & Luigi" and create another commit
- Verify you have two separate commits
- Squash the latest two commits into one commit
After you complete the exercise
Answer the following:
- What is the reason for squashing commits?
- Is it possible to squash more than 2 commits?
Git Basics 8 questions
- #8How do you know if a certain directory is a git repository?
- #9Explain the following: git directory, working directory and staging area
- #10What is the difference between git pull and git fetch?
- #11How to check if a file is tracked and if not, then track it?
- #12Explain what the file gitignore is used for
- #13How can you see which changes have done before committing them?
- #14What git status does?
- #15You've created new files in your repository. How to make sure Git tracks them?
Scenarios 2 questions
- #16You have files in your repository you don't want Git to ever track them. What should you be doing to avoid ever tracking them?
- #17A development team in your organization is using a monorepo and it's became quite big, including hundred thousands of files. They say running many git operations is taking a lot of time to run (like git status for example). Why does that happen and what can you do in order to help them?
Branches 7 questions
- #18What's is the branch strategy (flow) you know?
- #19True or False? A branch is basically a simple pointer or reference to the head of certain line of work
- #20You have two branches - main and devel. How do you make sure devel is in sync with main?
- #21Describe shortly what happens behind the scenes when you run git branch
- #22When you run git branch how does Git know the SHA-1 of the last commit?
- #23What unstaged means in regards to Git?
- #24True or False? when you git checkout some_branch, Git updates .git/HEAD to /refs/heads/some_branch
Merge 5 questions
- #25You have two branches - main and devel. How do you merge devel into main?
- #26How to resolve git merge conflicts?
- #27What merge strategies are you familiar with?
- #28Explain Git octopus merge
- #29What is the difference between git reset and git revert?
Rebase 11 questions
- #30You would like to move forth commit to the top. How would you achieve that?
- #31In what situations are you using git rebase?
- #32How do you revert a specific file to previous commit?
- #33How to squash last two commits?
- #34What is the .git directory? What can you find there?
- #35What are some Git anti-patterns? Things that you shouldn't do
- #36How do you remove a remote branch?
- #37Are you familiar with gitattributes? When would you use it?
- #38How do you discard local file changes? (before commit)
- #39How do you discard local commits?
- #40True or False? To remove a file from git but not from the filesystem, one should use git rm