Data Engineering

Git & GitHub - Fundamentals

Branching, merge, rebase, pull requests, gitflow, .gitignore, hooks, CI/CD workflows

20 interview questionsยท
Junior
1

Which command initializes a new Git repository in an existing directory?

Answer

The git init command creates a new Git repository in the current directory by initializing the .git subdirectory containing all files needed for versioning. This command is the first step to start tracking changes in an existing project.

2

What is the difference between git clone and git init?

Answer

git init creates a new empty repository in the current directory, while git clone copies an existing remote repository to the local machine, including the full commit history and branches. git clone also automatically sets up the connection with the remote repository (origin).

3

Which command creates a new branch and switches to it in a single operation?

Answer

The command git checkout -b branch_name creates a new branch and immediately switches to it. Since Git 2.23, git switch -c branch_name can also be used and is more explicit. These commands avoid doing git branch followed by git checkout.

4

What is the main difference between git merge and git rebase?

5

Why should rebasing commits already pushed to a shared branch be avoided?

+17 interview questions

Master Data Engineering for your next interview

Access all questions, flashcards, technical tests, code review exercises and interview simulators.

Start for free