All Flashcards
What is version control?
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.
What is Git?
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
What is a Git repository?
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.
What is a Git branch?
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.
What is merging?
Merging consists of joining branches. For example, when developers incorporate their peer-reviewed changes from a feature branch into the main branch.
What is continuous integration?
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 do CI and version control relate to one another?
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.
What’s the difference between continuous integration, continuous delivery, and continuous deployment?
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.
Is security important in CI/CD? What mechanisms are there to secure it?
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.
What is TDD?
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.
What does git clone do?
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.
What does the command git config do?
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»”
Can you explain head in terms of git and also tell the number of heads that can be present in a repository?
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
conflict
Git usually handles feature merges automatically but sometimes while working in a team environment, there might be cases of conflicts such as:
- When two separate branches have changes to the same line in a file
- 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.
Tell me something about git stash?
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.