chap 3 Flashcards

1
Q

Add a file

A

git add filename

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

Adding the Changes to an Existing File

A

git add filename

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

Adding Partial Changes

A

git add -p
git add –patch (-p)
This is an important feature, since it helps you to make well- factored commits. When you’re done with some editing and ready to commit, you may realize that you’ve made changes that ought to be represented by more than one commit; perhaps you’ve fixed two bugs in the same file, or tidied up some unrelated comments while you were at it. git add -p allows you to con‐ veniently split the work up into separate commits.

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

Adding Partial Changes to particular file

A

git add -p filename

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

Include all files in the current index; this includes changed and deleted files, but not new ones.

A

git add -u

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

Include all filenames in the index and in the working tree; this stages new files as well.

A

git add -A

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

remove a file

A

git rm filename
This does two things:
1. Deletes the file’s entry from the index, scheduling it for re‐moval in the next commit
2. Deletes the working file as well, as with rm filename

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

Renaming a file or moving a directory in Git

A

git mv foo bar

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

Remove files from statging

A

git reset // for all files

git reset filename // particular file

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

Show the changes that are in staging and ready for commiting

A

git diff –cached

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

Commit and add a message

A

git commit -m “an interesting commit message”

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

commit workflow

A
  1. Use git add (with various options) to stage a subset of your changes.
  2. Run git stash –keep-index. This saves and undoes your outstanding, unstaged changes while preserving your stag‐ ed changes in the index, and resets your working tree to match the index.
  3. Examine this working tree state to make sure your selection of changes makes sense; build and test your software, for example.
  4. Run git commit.
  5. Now, use git stash pop to restore your remaining unstag‐ ed changes, and go back to step 1. Continue this process until you’ve committed all your changes, as confirmed by git status reporting “nothing to commit, working direc‐ tory clean.”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly