Basics Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Create a new Git repository.

A

git init

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

Inspect the contents of the working directory and staging area.

A

git status

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

Add some files from the working directory to the staging area.

A

git add FILENAME1 FILENAME2

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

Show the difference between the working directory and the staging area.

A

git diff FILENAME1

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

Permanently store file changes from the staging area in the repository.

A

git commit -m “msg to save with the commit”

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

Show a list of all previous commits.

A

git log

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

See the HEAD commit.

A

git show HEAD

The output of this command will display everything the git log command displays for the HEAD commit, plus all the file changes that were committed.

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

Restore the file in your working directory to look exactly as it did when you last made a commit.

Name the shortcut of the command.

A

git checkout HEAD FILENAME1

Shortcut:
git checkout – filename

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

Reset (unstage) the file in the staging area to be the same as the HEAD commit.

A

git reset HEAD FILENAME1

It does not discard file changes from the working directory, it just removes them from the staging area.

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

Rewind to the part before the wrong turn. Set HEAD to the state of the previous commit.

A

git reset -commit_SHA-

-commit_SHA-: first 7 characters of the SHA of a previous commit. E.g.

git reset 5d69206

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

Add every file in the working directory to the staging area, instead of adding each file individually.

A

git add .

It is faster than specifying each file individually, but it’s easy to accidentally add files you don’t want there.

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

Identify on which branch you are working

A

git branch

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

Create a new branch.

Switch to the new branch.

A

git branch NEWBRANCH

git checkout NEWBRANCH

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

Merge the new branch into master branch.

First need to switch back to the master.

A

git checkout master

git merge NEWBRANCH

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

After the branch has been integrated into the master, it has served its purpose and can be deleted. Delete the branch.

A

git branch -d NEWBRANCH

If the branch was never merged into master we need the -D option.

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