Command Line, Git, and GitHub Basics Flashcards
a text-based environment where you can do things like create, move, copy, and delete files and folders, using different commands that are like mini-programs.
The command line
What is used to keep track of changes in files within a project. It allows you to take snapshots of a project at different points in time, create different versions of a project, and move between and even combine those different versions.
Version Control ystem
change directory, used to move from one directory (a.k.a., folder) to another
cd: cd ~ = home directory ; cd .. is a shortcut for the parent directory
print working directory, used to print the name of the folder you’re currently in
pwd
list, used to list the contents of a directory
ls
make directory, used to create a new directory
mkdir. For multiple files use: mkdir -p test/cats/dogs/bears
used to create a new (empty) file with a given name
touch
remove, used to remove a file (or folder)
rm
remove directory, used to remove a directory
rmdir
move, used to move a file or directory
mv
copy, used to copy a file or directory
cp
list all file including hidden
ls -a
(short for conCATenate) is used to print out the contents of a file to the command line.
cat command ex: cat file_folder/file.txt
To make a file or folder hidden, all you have to do is use a _______ as the first character in the name.
period (.) example: touch .hidden_file.txt
To hide a file on Windows, you must set the file’s _____ to hidden as well.
attribute : This can be done in Git Bash using the attrib command. Type attrib +h plus the file path in quotations. For example:
$ attrib +h “C:\Users\benvi\test.hidden-file.txt”
deleting in the command line environment is
permanent
use ____ to get an interactive prompt that will tell you what you’re about to delete, and ask you to confirm that you really want to delete it.
rm -i
If you need to delete a directory that has files or other directories in it, you’ll need to use the rm command along with the
-r and -f flags. The -r flag stands for “recursive” and will attempt to remove subfolders within the target folder. The -f flag will automatically remove files in the target folder and its subfolders without asking for confirmation. You could also run rm -r folder-to-be-removed, and this will allow you to delete the folder and its contents, but you’ll be prompted along the way to confirm deletion of individual files.
Copying a file or folder is similar to moving it, except that
the original is retained
two key ideas to grasp about Git, and everything else more or less falls out from them:
taking snapshots of code and creating distinct branches of code.
makes it safe to make deep (or shallow) changes to your code with less fear that you’re going to “destroy everything”.
snapshots
allow you to have different, diverging versions of a code repository.
branches
set up a global user name and user email for Git.
git config –global user.name “Beyonce Knowles”
git config –global user.email “beyonce@thinkful.com”
used to initialize a new Git repository
git init -
used to find out the current state of the repository (aka, repo, for short)
git status -
used to stage new or changed files. We’ll discuss the idea of staging changes in a moment
git add -
used to take a snapshot of the repo at a point in time
git commit -
used to see what has changed in a repo since the last commit
git diff –
used to reset your repository to a prior state.
git reset –
used to look at a prior state of the repository
git checkout –
Git’s version control system knows about a file and is watching it
Git is tracking a file. If a tracked file has been included in a commit, Git will be able to tell us how it’s changed since the last commit and the present moment.
like telling Git, “Hey pay attention to the (new) state of this file at this particular moment.
When you stage a change to a file
snapshot does not happen until you commit a set of staged changes
committing a file
formally request to merge one version of a repo into another. GitHub has a great UI for collaboratively discussing, reviewing, and approving pull requests.
a pull request