Introduction Flashcards
What is a Version Control System (VCS)?
It is a system that allows me to keep track of changes made to files. It is especially powerful for keeping track of text files, but it can be extended to configuration and data files as well as documentation.
What is a commit?
Commit is a collection of changes made to one or more files from a project at any given time,
What means for Git to be a distributed VCS?
It means that each contributor to a particular Git repository has its own local copy of this repository. The tracking and merging of changes to the repository do not require a central, coordinating server.
What are the two commands to create a Git directory on my machine:
- creating from another remote repository
- starting from scratch on my machine
Open the Terminal, navigate to the directory where I would like to put the Git directory and run one of those commands below
- git clone [insert URL]
- git init
What are the three main elements when using Git?
- Git Directory
- Stagging Area (or Index)
- Working Tree
Explain how a simple Git workflow works, from creating a new file/making changes to an existing one to finally committing it to the Git directory.
Start: create a new file on the Git directory or modify an existing one
In order for these changes to be tracked, I need to add this file to the Stagging Area.
Finally, I need to commit the content of the Stagging Area to the Git directory in order to capture the current state of the project at this moment in a commit.
Explain the Git Directory
Git Directory is a directory that will contain all the files that constitute a project as well as the history of the changes made to these files. Each snapshot of the project at any given time is called a commit.
Explain the Stagging Area, also called Index
The Stagging Area is a file that stores the information (i.e. files) that will constitute the next commit.
Explain the Working Tree
The Working Tree is a directory that exists outside of the Git directory and that contains the current version of the files in which I am working at. It can be viewed as a SANDBOX where I can do development until files are ready to be committed.
The Working Tree contains both the tracked and untracked files.
Explain the flow of the status of file in a Git workflow
- File usually starts at a modified stated (or in some cases as a new file)
- By using git add, the status of the file changes to stagged
- Finally, by using git commit, the status is ultimately changed to commited
What is the output from the command below?
$ git status
It will show the status of both the Working Tree and the Stagging Area, eventually showing the status of both tracked and untracked files.
If I navigate to the Git directory and run the command below, what would be the output?
$ ls -la .git/
Explain the -la
Output will be the content of the Git Directory (folder)
- l (will show the long format for the output)
- a –> will show all files (even the ones hidden)
How to use the diff command to check the difference between the following two files?
script.py
script_reviewed.py
diff -u [reference file name] [new file name]
$ diff -u script.py script_reviewed.py
The -u argument is related to the format of the output
How to create a .diff file with the changes between the following two files?
script.py
script_reviewed.py
$ diff script.py script_reviewed.py > script.diff
How to apply changes to my reference file from a .diff?
reference file: script.py
script.diff
$ patch script.py < script.diff