Git & Git Hub Flashcards

1
Q

What is a version control system?

A

A system that tracks the differences between versions of files, typically used in software development.

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

What popular method is used to track software versions?

A

Version control technologies like Git and GitHub.

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

What is Git?

A

Git is a version control system designed to help users keep track of changes to files within their projects.

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

Who designed Git and why?

A

Linus Torvalds designed Git to manage changes to the Linux kernel, which has thousands of contributors.

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

What are some benefits of Git over other version control systems?

A

Git offers better speed, performance, reliability, free and open-source access, and an accessible syntax.

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

What is GitHub?

A

GitHub is a Cloud-based hosting service that lets you manage Git repositories from a user interface.

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

What is a Git repository?

A

A Git repository is used to track all changes to files in a specific folder and keep a history of those changes.

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

What additional features does GitHub provide beyond Git?

A

GitHub provides features like access control, pull requests, automation, documentation, ticketing, and project management.

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

How is GitHub like a social network?

A

GitHub users have profiles, can follow other users, and contribute to public projects from anywhere in the world.

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

What do you do after choosing the owner of the repository?

A

Input a repository name.

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

What file is often initialized with a new repository?

A

A README.md file.

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

What is a README.md file?

A

A markdown file used for documentation, which is shorthand for creating HTML pages.

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

What is the main branch in a Git repository?

A

The main branch is the default branch of the repository, also known as the main line.

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

What does the ‘Go to file’ button do in GitHub?

A

It allows users to view and access the files in the repository.

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

What command is used to clone a repository using HTTPS?

A

git clone followed by the HTTPS URL.

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

What command is used to list directories and hidden files in the terminal?

A

ls -la.

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

What is the .git directory?

A

A hidden folder that contains Git-related information for source control.

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

What is GitHub?

A

A cloud-based hosting service that lets you manage Git repositories from a user interface.

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

What command is used to navigate into a directory in the terminal?

A

cd followed by the directory name.

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

What does the command ‘ls -la’ do?

A

It lists all files and folders, including hidden ones.

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

What is the .git folder?

A

A hidden folder used to track all changes in a Git repository.

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

What are the three states in the Git workflow?

A

The three states are modified, staged, and committed.

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

What does it mean when a file is in the modified state?

A

The file has been changed but is not yet tracked by Git.

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

What is the staged state in Git?

A

The file is added to the staging area, where changes are tracked before being committed.

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

What does it mean when a file is in the committed state?

A

The file has been saved and a snapshot of the current changes has been taken.

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

What is the purpose of committing a file in Git?

A

To save the file and create a snapshot of the current changes.

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

What does the Git workflow involve?

A

A file is added from the working directory to the staging area, committed, and pushed to the remote repository.

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

What can be done after pushing a file to a remote repository?

A

The file can be fetched, checked out, or merged to a working directory.

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

What does the pwd command do?

A

It prints the working directory, showing the current directory location.

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

What does the git status command show?

A

It displays the current branch, the status of the working directory, and any changes to commit.

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

What is the purpose of the git add command?

A

To track new or modified files, adding them to the staging area for the next commit.

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

What does the touch command do?

A

It creates a new empty file, like test.txt.

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

What happens after running git add on a file?

A

The file moves to the staged state, ready to be committed.

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

What is the git restore command used for?

A

It can be used to unstage changes or restore files to their previous state.

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

What does the clear command do in the terminal?

A

It clears the terminal screen, making it easier to read.

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

What does the git commit -m command do?

A

It commits the staged changes with a message attached, describing the changes.

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

What is the purpose of the git push command?

A

To upload the local commits to the remote repository on GitHub.

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

What does the message ‘nothing to commit, working tree clean’ mean?

A

It means there are no changes to commit, and the working directory matches the repository.

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

What command is used to create a new branch and switch to it in Git?

A

git checkout -b followed by the branch name.

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

What is the difference between git branch and git checkout -b?

A

git branch creates a new branch, while git checkout -b creates a new branch and switches to it.

41
Q

What is the purpose of a pull request?

A

To request a review and approval of changes made in a branch before merging into the main branch.

42
Q

How do you push changes from a new branch to the remote repository?

A

Use git push -u origin followed by the branch name.

43
Q

What is the difference between the main branch and a feature branch?

A

The main branch does not have knowledge of changes in a feature branch until the feature branch is merged back.

44
Q

What does the git pull command do?

A

It pulls the latest changes from the remote repository to the local machine.

45
Q

How can you merge a branch into the main branch?

A

Create a pull request on GitHub, review it, and then merge the branch into the main branch.

46
Q

What happens after a pull request is approved?

A

The changes from the feature branch are merged into the main branch.

47
Q

What command is used to check out the main branch in Git?

A

git checkout main.

48
Q

What command is used to delete a branch after merging it?

A

You can delete the branch from GitHub after merging, or use git branch -d followed by the branch name.

49
Q

What does the git push command do?

A

It uploads your local commits to the remote repository, syncing your local branch with the remote branch.

50
Q

Why is it important to run git pull before git push?

A

To retrieve the latest changes from the remote repository, reducing the chances of a merge conflict.

51
Q

What happens if your local branch is ahead of the remote branch?

A

Your local branch has changes that are not yet on the remote repository, which can be pushed using git push.

52
Q

What does the git pull command do?

A

It retrieves changes from the remote repository and merges them into your local branch.

53
Q

What is an auto merge in Git?

A

An automatic merge occurs when there are no conflicts between local and remote changes during a git pull or push.

54
Q

How does Git handle conflicts during git push?

A

Git will fail the push if there are conflicts between local and remote files, requiring a manual resolution.

55
Q

How can you check the contents of a file before and after git pull?

A

You can use the cat command to display the file contents.

56
Q

What information does git status provide?

A

It shows the current branch, whether there are uncommitted changes, and whether the branch is ahead or behind the remote branch.

57
Q

What is a workflow in programming?

A

A series of steps or processes that guide developers through tasks, ensuring smooth collaboration and deployment.

58
Q

What is feature branching?

A

Feature branching is a workflow where a new branch is created from the main line to work on a feature, and then merged back into the main branch after completion.

59
Q

Why is it important to keep the main branch clean in feature branching?

A

The main branch serves as the source of truth for the project, and changes are made in feature branches to prevent disruptions in the main branch.

60
Q

What is the purpose of a pull request in feature branching?

A

A pull request allows developers to review and approve changes made in a feature branch before merging them into the main branch.

61
Q

What command should you run before creating a new branch to ensure you have the latest code?

A

git pull.

62
Q

How do you create a new branch in Git?

A

Use the git checkout -b command followed by the branch name.

63
Q

What command is used to add new files to the staging area in Git?

A

git add followed by the file name or git add . to add all files.

64
Q

What is the purpose of the -m flag in git commit?

A

It allows you to include a message describing the changes being committed.

65
Q

What is the difference between committing and pushing in Git?

A

Committing adds changes to the local branch, while pushing sends those changes to the remote repository for others to see.

66
Q

What is the purpose of the .git folder?

A

The .git folder tracks all changes across a project and contains information about branches, commits, and other version control data.

67
Q

What is the HEAD file in Git?

A

The HEAD file is a pointer inside the .git folder that refers to the current commit or branch you’re working on.

68
Q

How can you view the current branch in Git?

A

You can run the command cat .git/HEAD to see which branch the HEAD is pointing to.

69
Q

What happens when you switch branches using git checkout?

A

When switching branches, the HEAD pointer is moved to the new branch, indicating that you are now working in that branch.

70
Q

What command can be used to verify the current commit hash ID in Git?

A

Use the command cat .git/refs/heads/ to check the current commit’s hash ID for a branch.

71
Q

How does the commit hash ID change after a commit?

A

Each commit generates a new hash ID that updates the current branch’s reference in the .git/refs/heads folder.

72
Q

What is the function of the git add command?

A

git add stages changes to be committed in Git.

73
Q

What does git commit -m do?

A

git commit -m commits staged changes with a message describing the changes.

74
Q

How can you verify if the commit ID has changed after a commit?

A

Use the command cat .git/refs/heads/ to check if the commit hash ID has updated after the commit.

75
Q

What is the purpose of the git diff command?

A

git diff is used to compare changes between files, branches, or commits, showing exactly what content was added or removed.

76
Q

How do git status and git diff complement each other?

A

git status shows the names of the changed files, while git diff shows the specific changes made within those files.

77
Q

What does a minus symbol represent in git diff output?

A

A minus symbol indicates content that has been removed compared to the previous version.

78
Q

What does a plus symbol represent in git diff output?

A

A plus symbol indicates content that has been added compared to the previous version.

79
Q

How can you compare a file against the HEAD using git diff?

A

Use the command git diff HEAD to compare the current state of a file against its last committed version.

80
Q

How can you use git diff to compare two specific commits?

A

Use git log to get the commit IDs, then run git diff to compare changes between the two commits.

81
Q

How do you compare changes between branches using git diff?

A

Use git diff to compare the differences between two branches.

82
Q

What is the purpose of the pretty flag in git log?

A

The pretty flag is used to display the commit history in a more readable format.

83
Q

What is the purpose of the git blame command?

A

git blame shows the changes made to a specific file, including the author, date, and time for each line of the file.

84
Q

What information does git blame provide for each line of a file?

A

git blame provides the commit ID, author, timestamp, line number, and the actual change for each line.

85
Q

How do you run the git blame command on a file?

A

Type git blame followed by the file name (e.g., git blame feature.js).

86
Q

What does the commit ID represent in git blame?

A

The commit ID is a reference to the specific commit where the change occurred.

87
Q

How can you limit git blame output to specific lines in a file?

A

Use the -L flag with git blame, followed by the starting and ending line numbers (e.g., git blame -L 5,15 ).

88
Q

How can you view the actual changes of a specific commit from git blame?

A

You can copy the commit ID from git blame and use it with the git log -p command to see the detailed changes.

89
Q

What does the -l flag do in git blame?

A

The -l flag in git blame allows you to format the output, such as showing full commit IDs or changing the date format.

90
Q

What is the difference between git blame and git log?

A

git blame shows who made changes to each line of a file, while git log shows the detailed history of changes in commits.

91
Q

What is the first step to fork a repository on GitHub?

A

Click the ‘Fork’ button on the GitHub repository page.

92
Q

What happens after you click the ‘Fork’ button on GitHub?

A

You select the account where the repository will be forked.

93
Q

What is the purpose of forking a repository?

A

Forking creates a copy of a repository in your own GitHub account to work on independently from the original project.

94
Q

What is the command to create a new branch after forking a repository?

A

git checkout -b .

95
Q

How do you commit changes after making edits to a forked repository?

A

Use git commit -m followed by a message to commit your changes.

96
Q

How do you push changes from your local forked repository to the remote GitHub repository?

A

Use git push -u origin to push changes to the remote repository.

97
Q

What is the next step after pushing changes to the remote repository in GitHub?

A

Create a pull request to merge the changes back into the original repository.

98
Q

What does a pull request allow the original repository owner to do?

A

It allows the repository owner to review the changes and decide whether to accept or decline them.