Git: Getting Started Flashcards

1
Q

What is a DVCS?

A
  • A DVCS is a type of version control system.
  • Each user has a local copy of the complete history of the project (repository).
  • Users can work offline.
  • Content is synchronized between repositories by pulling content from or pushing content to a remote repository.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
  • What is a git repository?
  • What is a commit?
  • What is a git branch?
  • What is a pull request?
A
  • A series of snapshots or commits.
  • Each version of the project is called commit.
  • All commits belong to a branch (an independent line of development of the project). By default there is a single branch called master
  • Request to merge your branch into another branch.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
  • What is the git basic syntax?
A
  • git [command] [–flags] [arguments]

Example:
git status #check status of the local repository
git status –short #just provides critical status information
git help #displays overall git help
git help init #displays help information for the init command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
  • Explain how to read certain git information, for example what does –flag mean?
A
  • -f or –flag Dash or double dash change the command’s behaviour. For example: –short
  • | Vertical bar represents OR
  • [optional] Optional values are surrounded by brackets
  • <placeholders> are surrounded by angle brackets, indicates where a specific value should be positioned. For example: git commit -m <message>
    </message></placeholders>
  • [<optional>]</optional>
  • () Parenthesis used for grouping
  • – Standalone dashes indicate that what follows is a file or path and are used to avoid ambiguity. For example: git checkout experiment (could be file or path) git checkout −−
    experiment (is a file).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does git config syntax look like? Give example of a use of git config.

A

Syntax: git config [–local|–global|–system] <key> [<value>]
This information is included in any commit that you make to your repository.
--system: every repository for all users on your computer.
--global: every repository that you as specific user use on your computer.
--local or no flag: only current repository.</value></key>

Example:
git config –global user.name “Maider”
git config –global user.email “maider.abad@esade.edu”

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

Explain what each git location is used for.

A

Working tree - contains the project file and directories of a single commit

Staging area - contains the list of files that will be included in the next commit

Local repository - Contains all the commits

Remote repository - Contains the commits on a remote dir

Project dir - Contains the working tree and a hidden .git repo that includes the staging area and local repo

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
  • What do the following commands do?
    1. git init
    2. git status
    3. git add / git add .
    4. git -m commit ‘message’
    5. git log
A
  1. git init - initialize (create) a git repository.
  2. git status - to view the status of the files in the working tree and staging area.
  3. git add - to add content to the staging area. / We can add all the untracked or modified files using git add .
  4. Adds staging area content to the local repository.
  5. git log - to view the commit history.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
  • Does a remote repository have a staging area or a working tree, give an example of a remote repository.
A
  • It is a ‘bare’ repository, there is not staging area or working tree.
  • GitHub is a remote git repository option.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a .gitignore file?

A
  • .gitignore file tells Git which files and directories to ignore when you make a commit.
  • You can specify the files or parts of your project you do not want to share.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is git clone used for?
What is git remote -v used for?

A
  • git clone - to create a local copy of a remote repository.
  • git clone < url/to/yourproject.git > [localprojectname]
  • git remote − − verbose| − v Displays information of the remote repositories associated to
    the local repository
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do I add a local repo to a remote one?

A
  • git remote add < name > < url > - to synchronize local and remote repositories.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do i commit to a remote repository?

A
  • git push [−u] [< repository >] [< branch >] - to write commits for a branch to a remote repository. For example: git push −u origin master < repository > can be a name (shortcut) or URL.
    For example: origin or https://github.com/maider-abad/repositoryA.git
    −u tracks the relationship between the local branch and the corresponding remote branch
How well did you know this?
1
Not at all
2
3
4
5
Perfectly