All Flashcards

1
Q

What is version control?

A

Version control is a set of practices and tools for managing codebases. Developers use version control to keep track of every line of code, and share, review, and synchronize changes among a team.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Git?

A

Git is the most popular version control tool. It uses a distributed repository model that can efficiently handle projects of any size. the model brings a local copy of the complete repository to every team member’s computer, so they can commit, branch, and merge locall

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a Git repository?

A

A Git repository keeps track of every file in a software project. The repository serves as an index for all files and changes in the project, allowing developers to navigate to any point in the project’s history.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a Git branch?

A

A Git branch is an independent line of development, usually created for working on a feature. Branches let developers code without affecting the work of other team members.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is merging?

A

Merging consists of joining branches. For example, when developers incorporate their peer-reviewed changes from a feature branch into the main branch.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is continuous integration?

A

Continuous Integration (CI) is a software development methodology where developers — following the trunk-based model — merge their changes to the main branch many times per day.

CI is supported by automated tests and a build server that runs them on every change. As a result, failures are made visible as soon as they are introduced and can be fixed within minutes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do CI and version control relate to one another?

A

Every change in the code must trigger a continuous integration process. This means that a CI system must be connected with a Git repository to detect when changes are pushed, so tests can be run on the latest revision.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What’s the difference between continuous integration, continuous delivery, and continuous deployment?

A

Continuous integration (CI) executes the sequence of steps required to build and test the project. CI runs automatically on every change committed to a shared repository, offering developers quick feedback about the project’s state.

Continuous delivery is an extension of CI. Its goal is to automate every step required to package and release a piece of software. The output of a continuous delivery pipeline takes the form of a deployable binary, package, or container.

Continuous deployment is an optional step-up from continuous delivery. It is a process that takes the output from the delivery pipeline and deploys it to the production system in a safe and automated way.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Is security important in CI/CD? What mechanisms are there to secure it?

A

Yes. CI/CD platforms have access to all kinds of sensitive data such as API keys, private repositories, databases, and server passwords. An improperly secured CI/CD system is a prime target for attacks and can be exploited to release compromised software or to get unauthorized access. A CI/CD platform must support mechanisms to securely manage secrets, and control access to logs and private repositories.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is TDD?

A

Test-Driven Development (TDD) is a software design practice in which a developer writes tests before code. By inverting the usual order in which software is written, a developer can think of a problem in terms of inputs and outputs and write more testable (and thus more modular) code.

The TDD cycle consists of three steps:

Red: write a test that fails.
Green: write the minimal code that passes the test.
Refactor: improve the code, and make it more abstract, readable, and optimized.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does git clone do?

A

The command creates a copy (or clone) of an existing git repository. Generally, it is used to get a copy of the remote repository to the local repository.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does the command git config do?

A

The git config command is a convenient way to set configuration options for defining the behavior of the repository, user information and preferences, git installation-based configurations, and many such things.

For example:
To set up your name and email address before using git commands, we can run the below commands:

git config –global
user.name
“«your_name»”

git config –global user.email “«your_email»”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Can you explain head in terms of git and also tell the number of heads that can be present in a repository?

A

A head is nothing but a reference to the last commit object of a branch.
For every repository, there will always be a default head referred to as “master” or now “main” (as per GitHub) but there is no restriction to the count of heads available. In other words, it can have any number of heads.
Usages:

  • To go or checkout to 1 commit before the latest commit, we use git checkout HEAD~1
  • To uncommit the last 3 commits without losing the changes, we first run git reset HEAD~3. Then we can see the changes made in the last 3 commits and then update it manually and commit it finally.
  • In order to uncommit the last 3 commits and also remove the changes, we can run the command: git reset –hard HEAD~3. This command will completely remove all the changes.
  • To look into the changes made in the last 3 commits, we can run git diff HEAD~3
  • To make a new commit by reverting the last 3 commits, we can run the command: git revert –no-commit HEAD~3…HEAD
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

conflict

A

Git usually handles feature merges automatically but sometimes while working in a team environment, there might be cases of conflicts such as:

  1. When two separate branches have changes to the same line in a file
  2. A file is deleted in one branch but has been modified in the other.

These conflicts have to be solved manually after discussion with the team as git will not be able to predict what and whose changes have to be given precedence.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Tell me something about git stash?

A

Git stash can be used in cases where we need to switch in between branches and at the same time not wanting to lose edits in the current branch. Running the git stash command basically pushes the current working directory state and index to the stack for future use and thereby providing a clean working directory for other tasks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the command used to delete a branch?

A

To delete a branch we can simply use the command git branch –d [head].
To delete a branch locally, we can simply run the command: git branch -d <local_branch_name>
To delete a branch remotely, run the command: git push origin --delete <remote_branch_name>
Deleting a branching scenario occurs for multiple reasons. One such reason is to get rid of the feature branches once it has been merged into the development branch.</remote_branch_name></local_branch_name>

17
Q

between git pull and git fetch.

A

git pull
This command pulls new changes from the currently working branch located in the remote central repository.

git fetch
This command is also used for a similar purpose but it follows a two step process:
1. Pulls all commits and changes from desired branch and stores them in a new branch of the local repository.
current
2. For changes to be reflected in the current / target branch, git fetch should be followed by git merge command.

18
Q

pr and brnch

A

pull request
This process is done when there is a need to put a developer’s change into another person’s code branch.

branch
A branch is nothing but a separate version of the code.

19
Q

What is git rebase and how can it be used to resolve conflicts in a feature branch before merge?

A

In simple words, git rebase allows one to move the first commit of a branch to a new starting location. For example, if a feature branch was created from master, and since then the master branch has received new commits, git rebase can be used to move the feature branch to the tip of master. The command effectively will replay the changes made in the feature branch at the tip of master, allowing conflicts to be resolved in the process. When done with care, this will allow the feature branch to be merged into master with relative ease and sometimes as a simple fast-forward operation.

20
Q

How do you squash last N commits into a single commit?

A

Squashing multiple commits into a single commit will overwrite history, and should be done with caution. However, this is useful when working in feature branches. To squash the last N commits of the current branch, run the following command (with {N} replaced with the number of commits that you want to squash):

git rebase -i HEAD~{N}
Upon running this command, an editor will open with a list of these N commit messages, one per line. Each of these lines will begin with the word “pick”. Replacing “pick” with “squash” or “s” will tell Git to combine the commit with the commit before it. To combine all N commits into one, set every commit in the list to be squash except the first one. Upon exiting the editor, and if no conflict arises, git rebase will allow you to create a new commit message for the new combined commit.