Learning Git Flashcards
What is a repository?
A repository is a copy of a Git project.
A repository (also called repo) is how we refer to a project version controlled by Git.
What is a commit?
A commit in Git is basically one version of a project. You can think of it as a snapshot of a project, or a standalone version of a project that contains references to all the files that are part of that commit.
Every commit has a commit hash (also called commit ID).
Every time you want to save a new version of a project, you can make a commit.
What is Git?
Git is a technology used to track changes to a project and to help multiple people to collaborate on a project. At a basic level, a project version controlled by Git consists of a folder with files in it, and Git tracks the changes that are made to the files in the project. This allows you to save different versions of the work you are doing, which is why we call Git a version control system.
Git is a version control system that lets you track the history of a project and collaborate with other people.
What are hidden files and hidden directories?
Hidden files and directories are files or directories that store information that we, as users, don’t need to access, such as application configurations and various system settings.
The names of many hidden files and directories start with a dot (.)
What are Git Configurations?
Git configurations are settings that allow you to customize how Git works. They consist of variables and their values, and they are stored in a couple of different files.
git config --global --list
List the variables in the global Git configuration file and their values.
What are the two types of Git repositories?
- local repository - a repository that is stored on a computer
- remote repository - a repository that is hosted on a hosting device
A hosting service is a company that provides hosting for projects using Git. Github is a hosting service.
What is the hidden directory .git for?
A local repository is represented by a hidden directory called .git that exists within a project directory. It contains all the data on the changes that have been made to the files in a project.
How do you initialize a Git repository?
git init
Your current directory must be the project directory you want to turn into a repository when you execute this command
What is the following command:
git init -b <branch_name>
Initialize a Git repository and set the name for the initial branch to be branch_name
What are the 4 areas to be aware of in Git?
- Working directory
- Staging area
- Commit history
- Local repository
What is the Working Directory?
The working directory contains the files and directories in the project directory that represent one version of the project.
It is sort of like a workbench. It is where you add, edit, and delete files and directories. The working directory is where you make all the modifications to the contents of a project.
What is the staging area?
The staging area is similar to a rough draft space. It is where you can add and remove files, when you are preparing what you want to include in the next saved version of your project (your next commit).
The staging area allows you to choose which updated files (or changes) will be included in your next commit.
The staging area is represented by a file in the .git directory called index.
The index file is created only if you have added at least one file to the stating area in your project.
What is the commit history?
The commit history is where you can think of your commits existing. It is represented by the objects directory inside the .git directory.
Every time you make a commit, it is saved in the commit history.
What is a tracked file and an untracked file?
An untracked file is a file in the working directory that Git is not version controlling. It has never been added to the staging area and it has never been included in a commit; therefore, it is not part of the repository.
Once you add a file to the staging area and include it in a commit, the file becomes a tracked file. This is a file that is version controlled (in other words, a file that Git tracks).
Every new file in a project version controlled by Git needs to be explicitly added to the staging area and then included in a commit in order to become a tracked file.
Why is committing files/projects important?
Committing is important because it allows you to back up your work and avoid losing unsaved work. Once you’ve madea commit, that work is saved, and you’ll be ableto go back and look at that commit to see what your project looked like at that point in time.
Making a commit is a two-step process. What is that?
- Add all the files you want to include in the next commit to the staging area
- Make a commit with a commit message
What is the following command:
git status
This tells you the state of the working directory and the staging area. This is useful because in a project w/many files it is easy to lose track of what state the files in your working directory are in (i.e. which ones you have edited) and which files you’ve added to the staging area
What is the following command:
git add -A
Add all the files in the working directory that have been edited or changed to the staging area.
The “-A” part is an option that tells you to add all files.
What is the general rule when making commits?
The general rule is to group related changes together (in the staging area) when you make a commit. This allows you to keep your commits more organized.
Does git add command move or copy a file from the working directory to the staging area?
It copies the file from the working directory into the staging area.
Explain how commit is both a verb and a noun?
In Git, the verb to commit means to save something, and the nount (a commit) means a version of our project. So, to make a commit means to save a version of a project.
Explain the following command:
git log
To see a list of commits in the commit history, use
git log.
The
git logcommand lists the commits in a local repository in reverse chronological order. It didsplayes 4 pieces of info about each commit:
1. Commit hash
2. Author name and email address
3. Date and time commit was made
4. Commit message