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)
2
Q
Git Basic Workflow
A
- Modify files in your working directory
- Stage files adding snapshots of them to your staging area
- Do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your local Git repo
3
Q
Avoid Common Problems
A
- Do not edit repo manually
- Try not to make drastic changes all at once. Make multiple commits
- Always git pull before editing a file
- Do a git push after committing changes
4
Q
SVN repo approach
A
Central Repo Approach: Main repo is the only true source
5
Q
Git repo approach
A
Distributed repo approach
6
Q
SVN vs Git
A
- Greater redundancy and speed
* Branching and merging repo is more heavily used
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
8
Q
how do I create a new Git repo?
A
git init
9
Q
how do I commit the file with a message?
A
git commit -m “…”
10
Q
how do I unstage a change on a file before committing?
A
- git reset HEAD filename
OR
- git checkout –filename
11
Q
How do I view the status of my files in the working directory?
A
git status
12
Q
How do I see the difference between the working directory and my staging area?
A
git diff
13
Q
How do I see a log of all changes?
A
git log