3/1 - Version Control with Git Flashcards

1
Q

Repositories

A
  • Repository: A location storing a copy of all files
  • You don’t edit files directly in the repo, you edit the local working copy
  • Then you commit your edited files into the repo
  • Each user has their own copy (Example, in Git and Mercurial)
  • All user work on the same repository (Example, in CVS, Subversion)
  • Files in your working directory must be added to the repo in order to be tracked
  • Put source code (.java, .c), build files (Makefile, build.xml, icons, text) in the repo
  • Don’t put Object files(.o), executable files(.exe)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Git Basic Workflow

A
  1. Modify files in your working directory
  2. Stage files adding snapshots of them to your staging area
  3. Do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your local Git repo
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Avoid Common Problems

A
  1. Do not edit repo manually
  2. Try not to make drastic changes all at once. Make multiple commits
  3. Always git pull before editing a file
  4. Do a git push after committing changes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

SVN repo approach

A

Central Repo Approach: Main repo is the only true source

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

Git repo approach

A

Distributed repo approach

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

SVN vs Git

A
  • Greater redundancy and speed

* Branching and merging repo is more heavily used

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

git clone [local dir name]

A

to clone an existing repo to your current directory

  • Will create a directory named local dir name
  • Containing a working copy of files from the repo
  • And a .git directory
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

how do I create a new Git repo?

A

git init

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

how do I commit the file with a message?

A

git commit -m “…”

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

how do I unstage a change on a file before committing?

A
  1. git reset HEAD filename

OR

  1. git checkout –filename
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do I view the status of my files in the working directory?

A

git status

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

How do I see the difference between the working directory and my staging area?

A

git diff

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

How do I see a log of all changes?

A

git log

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