Git Flashcards

1
Q

Use git f____ to retrieve new work done by other people

A

Use git fetch to retrieve new work done by other people

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

command you use to view the changes in the files you are going to commit

A

git diff

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

view the changes in the staging area

A

git diff –cached

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

If you seem to have lost your history, check the r____ as your safety net.

A

If you seem to have lost your history, check the reflog as your safety net.

git reflog

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

To search the commit log for a text pattern:

A

git log –grep=”text here”

git log –grep=word

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

output git log with the first line only

A

git log –oneline

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

view the changes in all previous commits

A

git log -p

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

discard all changes you made in the working tree

A

git restore .

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

To unstage all files from the current change set:

A

git reset

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

The major benefit of rebasing (over merging) is that you get a much cleaner project h_____

A

The major benefit of rebasing is that you get a much cleaner project history

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

The golden rule of git rebase is to never use it on p____ branches.

A

The golden rule of git rebase is to never use it on public branches.

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

So, before you run git rebase, always ask yourself, “Is anyone else looking at this branch?” If the answer is yes, take your hands off the keyboard and start thinking about a non-destructive way to make your changes (e.g., the git r____ command).

A

So, before you run git rebase, always ask yourself, “Is anyone else looking at this branch?” If the answer is yes, take your hands off the keyboard and start thinking about a non-destructive way to make your changes (e.g., the git revert command).

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

If you would prefer a clean, linear history free of unnecessary merge commits, you should reach for git r____ instead of git merge when integrating changes from another branch.

A

If you would prefer a clean, linear history free of unnecessary merge commits, you should reach for git rebase instead of git merge when integrating changes from another branch.

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

The git s___ command takes your uncommitted changes (both staged and unstaged), saves them away for later use, and then reverts them from your working copy

A

The git stash command takes your uncommitted changes (both staged and unstaged), saves them away for later use, and then reverts them from your working copy

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

You can reapply previously stashed changes with git s____ p__

A

You can reapply previously stashed changes with git stash pop

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

If you decide you no longer need a particular stash, you can delete it with git stash d___

A

If you decide you no longer need a particular stash, you can delete it with git stash drop

17
Q

git b____ is used to examine specific points of a file’s history and get context as to who the last author was that modified the line.

A

git blame is used to examine specific points of a file’s history and get context as to who the last author was that modified the line.

18
Q

The -_ option will perform a “dry run” of git clean. This will show you which files are going to be removed without actually removing them.

A

The -n option will perform a “dry run” of git clean. This will show you which files are going to be removed without actually removing them.

$ git clean -n
Would remove untracked_file
19
Q

The git revert command can be considered an ‘undo’ type command, however, it is not a traditional undo operation. Instead of removing the commit from the project history, it figures out how to invert the changes introduced by the commit and appends a new commit with the resulting inverse content. This prevents Git from losing h____, which is important for the integrity of your revision history and for reliable collaboration.

A

The git revert command can be considered an ‘undo’ type command, however, it is not a traditional undo operation. Instead of removing the commit from the project history, it figures out how to invert the changes introduced by the commit and appends a new commit with the resulting inverse content. This prevents Git from losing history, which is important for the integrity of your revision history and for reliable collaboration.

20
Q

Reverting should be used when you want to apply the i_____ of a commit from your project history. This can be useful, for example, if you’re tracking down a bug and find that it was introduced by a s____ commit. Instead of manually going in, fixing it, and committing a new snapshot, you can use git revert to automatically do all of this for you.

A

Reverting should be used when you want to apply the inverse of a commit from your project history. This can be useful, for example, if you’re tracking down a bug and find that it was introduced by a single commit. Instead of manually going in, fixing it, and committing a new snapshot, you can use git revert to automatically do all of this for you.

21
Q

Other ‘undo’ commands like, git checkout and git reset, move the H___ and branch ref pointers to a specified commit. Git revert also takes a specified commit, however, git revert does not move ref p_____ to this commit.

A

Other ‘undo’ commands like, git checkout and git reset, move the HEAD and branch ref pointers to a specified commit. Git revert also takes a specified commit, however, git revert does not move ref pointers to this commit.

22
Q

git revert is able to target an individual commit at an arbitrary point in the h____, whereas git reset can only work backward from the c____ commit.

A

git revert is able to target an individual commit at an arbitrary point in the history, whereas git reset can only work backward from the current commit.

23
Q

The git r____ command is a complex and versatile tool for undoing changes with three primary forms of invocation that correspond to command line arguments: –soft, –mixed, –hard

A

The git reset command is a complex and versatile tool for undoing changes with three primary forms of invocation that correspond to command line arguments: –soft, –mixed, –hard

24
Q

The three git reset arguments each (–soft, –mixed, –hard) correspond to Git’s three internal state management mechanism’s, The Commit Tree (HEAD), The Staging Index, and The Working Directory.

A

The three git reset arguments each (–soft, –mixed, –hard) correspond to Git’s three internal state management mechanism’s, The Commit Tree (HEAD), The Staging Index, and The Working Directory.

25
Q

git reset moves both the H____ and branch r___s to the specified commit.

A

git reset moves both the HEAD and branch refs to the specified commit.

26
Q

The default invocation of git reset has implicit arguments of –m____ and HEAD

A

The default invocation of git reset has implicit arguments of –mixed and HEAD

27
Q

Rebase itself has 2 main modes: “m____” and “i_____” mode

A

Rebase itself has 2 main modes: “manual” and “interactive” mode

28
Q

From a content perspective, rebasing is changing the base of your branch from one commit to another making it appear as if you’d created your branch from a different c_____.

A

From a content perspective, rebasing is changing the base of your branch from one commit to another making it appear as if you’d created your branch from a different commit.

29
Q

The git checkout command accepts a -__ argument that acts as a convenience method which will create the new branch and immediately switch to it.

A

The git checkout command accepts a -b argument that acts as a convenience method which will create the new branch and immediately switch to it.

git checkout -b <new-branch>
30
Q

Passing the –m___ argument to the git log command will produce a log with a list of commits that conflict between the merging branches.

A

Passing the –merge argument to the git log command will produce a log with a list of commits that conflict between the merging branches.

31
Q

Executing git merge with the –a___ option will exit from the merge process and return the branch to the state before the merge began.

A

Executing git merge with the –abort option will exit from the merge process and return the branch to the state before the merge began.

32
Q

The git merge and git pull commands can be passed an -_ (strategy) option. The -_ option can be appended with the name of the desired merge strategy.

A

The git merge and git pull commands can be passed an -s (strategy) option. The -s option can be appended with the name of the desired merge strategy.

33
Q

The –g____ option draws an ASCII graph representing the branch structure of the commit history.

A

The –graph option draws an ASCII graph representing the branch structure of the commit history.

34
Q

see all config variables

A

git config -list