Git basics Flashcards

1
Q

What is the command to initialize a repo?

A

git init

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

What is the command to save a commit?

A

git commit -m “message”

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

What is the command to add files to a git repo?

A

git add filename

for all files in current directory

git add .

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

What is the typical git sequence to keep track of changes in a directory?

A
  1. Make dir changes
  2. Add the changes
  3. Commit the changes to repo with a message
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the best practices for writing a commit message?

A

Start with a short single line summary (less than 50 chars)

write in present tense

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

What is the command to view git logs?

A

git log

to show last n commits: git log -n 5

since a date:

git log –since/until

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

What command is use to tell which branch you are on and about untracked files?

A

git status

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

What command lets you discard changes in a tracked file?

A

git checkout – <file></file>

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

Command to list all branches and switch branch?

A

git branch - view all branches

git branch <branch> to create a new branch</branch>

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

How to connect a remote branch?

A

git remote add

<name> <url>
</url></name>

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

How does a rebase work vs a merge?

A

Merge adds changes from both branching paths on to the most recent common ancestor (add commits in parallel)

Rebase commits the branch in the parameter to the most recent common ancestor and then commits the current branch ahead of it (add commits in serial)

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

What is the command for rebasing?

A

git rebase <branch></branch>

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