Git: Getting Started Flashcards
What is a DVCS?
- 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.
- What is a git repository?
- What is a commit?
- What is a git branch?
- What is a pull request?
- 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.
- What is the git basic syntax?
- 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
- Explain how to read certain git information, for example what does –flag mean?
- -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).
What does git config syntax look like? Give example of a use of git config.
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”
Explain what each git location is used for.
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
- 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
- git init - initialize (create) a git repository.
- git status - to view the status of the files in the working tree and staging area.
- git add - to add content to the staging area. / We can add all the untracked or modified files using git add .
- Adds staging area content to the local repository.
- git log - to view the commit history.
- Does a remote repository have a staging area or a working tree, give an example of a remote repository.
- It is a ‘bare’ repository, there is not staging area or working tree.
- GitHub is a remote git repository option.
What is a .gitignore file?
- .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.
What is git clone used for?
What is git remote -v used for?
- 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 do I add a local repo to a remote one?
- git remote add < name > < url > - to synchronize local and remote repositories.
How do i commit to a remote repository?
- 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