Git Flashcards

1
Q

What is Git?

A

GIT is a distributed version control system and source code management (SCM) system with an emphasis to handle small and large projects with speed and efficiency.

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

What is Repository?

A

A repository contains a directory named .git, where git keeps all of its metadata for the repository. The content of the .git directory are private to git.

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

What is the command to write a commit message in Git?

A

Answer:
Use:

git commit -a
-a on the command line instructs git to commit the new content of all tracked files that have been modified. You can use

git add <file>
or</file>

git add -A
before git commit -a if new files need to be committed for the first time.

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

What is the difference between git pull and git fetch?

A

In the simplest terms, git pull does a git fetch followed by a git merge.

When you use pull, Git tries to automatically do your work for you. It is context sensitive, so Git will merge any pulled commits into the branch you are currently working in. pull automatically merges the commits without letting you review them first. If you don’t closely manage your branches, you may run into frequent conflicts.

When you fetch, Git gathers any commits from the target branch that do not exist in your current branch and stores them in your local repository. However, it does not merge them with your current branch. This is particularly useful if you need to keep your repository up to date, but are working on something that might break if you update your files. To integrate the commits into your master branch, you use merge.

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

What’s the difference between a pull request and a branch?

A

A branch is just a separate version of the code.

A pull request is when someone take the repository, makes their own branch, does some changes, then tries to merge that branch in (put their changes in the other person’s code repository).

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

What is Git fork? What is difference between fork, branch and clone?

A

A fork is a remote, server-side copy of a repository, distinct from the original. A fork isn’t a Git concept really, it’s more a political/social idea.
A clone is not a fork; a clone is a local copy of some remote repository. When you clone, you are actually copying the entire source repository, including all the history and branches.
A branch is a mechanism to handle the changes within a single repository in order to eventually merge them with the rest of code. A branch is something that is within a repository. Conceptually, it represents a thread of development.

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

You need to update your local repos. What git commands will you use?

A

It’s a two steps process. First you fetch the changes from a remote named origin:

git fetch origin
Then you merge a branch master to local:

git merge origin/master
Or simply:

git pull origin master
If origin is a default remote and ‘master’ is default branch, you can drop it eg. git pull.

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

What is “Staging Area” or “Index” in GIT?

A

Before completing the commits, it can be formatted and reviewed in an intermediate area known as ‘Staging Area’ or ‘Index’.

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

What is the function of git clone?

A

The git clone command creates a copy of an existing Git repository. To get the copy of a central repository, ‘cloning’ is the most common way used by programmers.

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

What is the function of git remote?

A

Git Remote: Git remote command helps you to create, delete, and view connections between remote and local. To view the original file of the copied repository, use the git remote command as

Command used: $ git remote

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

How do you create a Git repository?

A

To develop a repository in git, use the command “git init” on the created project directory. If the directory of the project is not created then you need to create a new directory and then run the command “git init”.

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

How git status is different from git diff?

A

Git Status: Git Status Shows the difference between the working directory and index.

Git Diff: Git Diff Shows the changes between commits and the working directory.

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

What is a ‘conflict’ in git?

A

A ‘conflict’ arises when the commit that has to be merged has some change in one place, and the current commit also has a change at the same place. Git will not be able to predict which change should take precedence.

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

How can conflict in git resolved?

A

To resolve the conflict in git, edit the files to fix the conflicting changes and then add the resolved files by running “git add” after that to commit the repaired merge, run “git commit”. Git remembers that you are in the middle of a merger, so it sets the parents of the commit correctly.

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

What is the syntax for “Rebasing” in Git?

A

The syntax used for rebase is “git rebase [new-commit] “

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

Have you ever done debugging with Git? How did you do this?

A

To debug with Git, you use git bisect to identify the first commit to introduce a bug by using automatic binary search. And git blame identifies the author of a commit, while git grep searches for any string or regular expression in any of the files in the staging area.

17
Q

What command do you use to return to a previous commit?

A

To return to a previous commit on a private, local repository, you’ll first want to run git log to pull up the branch’s history. Then, after identifying the version’s hash you want to go to, use the git reset command to change the repository to the commit.

For a public, remote repository, the git revert command is a safer option. It’ll create a new commit with the previous edits rather than delete commits from the history.

18
Q

What is GIT version control?

A

With the help of GIT version control, you can track the history of a collection of files and includes the functionality to revert the collection of files to another version. Each version captures a snapshot of the file system at a certain point of time. A collection of files and their complete history are stored in a repository.

19
Q

What is ‘git status’ is used for?

A

As ‘Git Status’ shows you the difference between the working directory and the index, it is helpful in understanding a git more comprehensively.

20
Q

What is the difference between Git & Github ?

A
  1. GIT : Git is a Version Control System.
    GITHUB : Github is a hosting platform for git repositories.

2.GIT : Git can be used independently.
GITHUB : Github is designed based on git repos.

  1. GIT : Git provides command-line tool.
    GITHUB : Github provides web-based Interface.

4.GIT : it is a software.
GITHUB : it is a service

  1. GIT : we can manage code locally.
    GITHUB : we can collaborate and can share code with others.

————MADHU VASANTH———–