Dev-ops/Git/Jira Flashcards
What is git add?
The git add command is used in Git to stage changes for inclusion in the next commit. It prepares modifications, additions, or deletions made to files in the working directory, marking them to be included in the upcoming commit snapshot. Note this command does not actually commit the changes but prepares them for staging.
What is git push?
The git push command is used in Git to upload local repository content to a remote repository. It transfers committed changes from the local repository to a remote one, typically on a server like GitHub or GitLab. This command enables collaboration by allowing users to share their changes with others on the same project.
What is git status?
The git status command displays the current state of the repository in Git. It provides information about which files have been modified, which are staged for the next commit, and which are untracked. It helps users track the progress of their work and identify any changes that need to be committed or staged.
What is a commit in Git?
A commit represents a snapshot of the changes made to files in a repository at a specific point in time. When you commit changes in Git, you are effectively saving the current state of your files and can provide a descriptive message that explains the changes made (which is recommended).
Each commit creates a unique identifier, allowing you to track the history of changes in the repository. Commits play a crucial role in version control, as they provide a way to revert to previous states of the project, review the history of changes, and collaborate with others by sharing updates.
What is branching in Git?
Branching refers to the practice of diverging from the main line of development (typically called the “master” branch) to work on new features, fixes, or experiments without affecting the main codebase. It allows multiple parallel lines of development to coexist within the same repository.
Each branch represents a separate line of development with its own set of commits, enabling developers to work on different features or fixes simultaneously. Branching facilitates collaboration, experimentation, and organization within a project, as changes made in one branch can be merged back into the main codebase once they are completed and tested.
What is a conflict in Git?
Conflicts arise when conflicting changes are made to the same part of a file or files by different contributors, typically during a merge or rebase operation. Git cannot automatically resolve these conflicting changes, requiring manual intervention by the user to resolve the discrepancies.
Thus, to resolve conflicts, the conflicted files must be reviewed and edited based on the best suited reconciliation before the resolved version is committed.
What is merge in Git?
Merging is a fundamental operation in Git that facilitates collaboration and the integration of changes across different branches in a project. Namely, a merge is the process of combining the changes from different branches into a single branch, typically the main branch (e.g., master or main).
A merge integrates the changes made in one branch with another, resulting in a new commit that combines the histories of both branches. You can learn more about how to resolve merge conflicts in Git with our separate tutorial.
What is a remote in Git?
A remote is a repository hosted on a server or another computer for collaboration and sharing code with others. It serves as a centralized location where developers can push their local changes and pull changes made by others.
Remotes are typically set up on hosting platforms like GitHub, GitLab, or Bitbucket, and they enable distributed development and facilitate teamwork by providing a common location for storing and synchronizing project code among multiple contributors.
What is the difference between git fetch and git pull?
The main difference between git fetch and git pull lies in what they do and how they update the local repository.
The git fetch command retrieves changes from a remote repository to the local repository. It updates the remote-tracking branches (e.g., origin/master) in the local repository to reflect the state of the remote repository, but it does not update the working directory or merge any changes into the current branch. This means that after fetching, you can review the changes made in the remote repository without affecting your local work.
The git pull command also retrieves changes from a remote repository, but it goes a step further by fetching changes and merging them into the current branch in one step. It essentially performs a git fetch followed by a git merge to incorporate the changes from the remote repository into the current branch.
How do you revert a commit that has already been pushed and made public?
The git revert <commit-hash> command can be used to revert a commit that has already been pushed and made public.</commit-hash>
The step-by-step process is as follows:
- Identify the commit you want to revert to by finding its commit hash. This can be done using the git log command to view the commit history and find the commit hash you want to revert.
- Once you have the commit hash, use the git revert command followed by the commit hash to create a new commit that undoes the changes introduced by the specified commit. For example:
What does git reset do?
The git reset command resets the current HEAD to a specified state. This means it can be used to undo changes, unstage files, or move the HEAD pointer to a different commit. Note there are three main modes of git reset:
–soft: Resets the HEAD pointer to a specific commit, keeping changes staged. Files remain modified in the working directory, allowing you to re-commit them.
–mixed: Resets the HEAD pointer to a specific commit, unstaging changes. Files remain modified in the working directory, but changes are not staged for commit.
–hard: Resets the HEAD pointer to a specific commit, discarding all changes in the working directory and staging area. Use with caution, as it permanently deletes uncommitted changes.
What is git stash?
git stash is a Git command that temporarily stores changes in the working directory that are not ready to be committed. It allows developers to save their modifications without committing them to the repository.
Stashing is useful when switching branches, but you don’t want to commit or lose your changes. Later, you can apply the stashed changes to your working directory or pop them off the stash stack to continue working on them.
What is a Container?
How many Docker components are there?
What are docker images?
What is a DockerFile?
Can you tell what is the functionality of a hypervisor
What can you tell about Docker Compose?
What is docker image registry?
Can you tell something about docker container?
What is a Docker Hub?
what is yaml?