Module 1 Flashcards
What is the goal of a version control system (VCS)?
To allow tracking of changes made to project files
I’ve prepared patch file (fixscript.patch) with changes required to fix a colleague’s script. How does he applies my change to his file?
patch original_file.py < fix_script.patch
I’m helping a colleague with a bug in a script called file1.py. I made a copy called file1_modified.py to fix the bug. What command do I need to run after solving the bug to send the patch to my colleague?
diff file1.py file1_modified.py > file1_fix.patch
Compares file_1modified against file1 and saves changes to file1_fix
What I need to provide to the patch
command?
- Original File
- Patch file (.diff)
What does the patch
command do?
It applies the changes contained in a diff file to another file.
What is the purpose of the diff
command?
To show the differences between two files
How can using the -u
flag with the diff
command provide more context for the changes being compared?
What are the git directory and the working tree?
The git directory contains all the changes and their history and the working tree contains the current versions of the files.
Git Directory: hidden database that stores all the information about your project’s history, changes, and different versions in this directory.
What is the difference between tracked and untracked files?
Tracked files are part of the snapshots (commits) while untracked filed are not included in the commits.
What is the next step after modifying a file tracked by Git?
We need to stage the file, so that the changes will be included in the next commit.
This is done via the git add <file_name>
command.
Describe the situation below
There was a change to a file called rearrange1.py in the working tree, but the file has not been added to the stagging area, meaning it will not be include in the next commit.
If we want to include it in the next commit, then we need to use git add
Describe the situation below
There was a change to a file called rearrange1.py in the working tree and the file was added to the stagging area, meaning it will be include in the next commit.
To commit it, we need to use git commit - m
and include a commit message.
Explain how the diff
command is used in practice and how does it show the difference between files?
What are the three main sections of a Git project and what does each section contain?
- Git Directory (Repository): This is where Git stores all the history of your project, including all commits, branches, and tags. Think of it as a hidden database for your project’s versions.
- Working Tree: This is the area where you directly work on your files. It contains the current version of your project that you see and edit.
- Staging Area (Index): This is a middle ground between your working tree and the Git directory. It’s where you prepare changes for the next commit. You can add or remove changes from the staging area before committing them to the Git directory. Index is a file.
What the possible states of a tracked file
A tracked file can be:
1. modified (changes made but not committed)
2. staged (changes marked for commit)
3. committed (changes stored in a snapshot).