This page has some quick info on git that you can use as a reference. This guide will be added to over the course of the semester. Please feel free to make a pull request with any additional information you think may be useful!
-
command line: a tool for entering text commands into a computer (varies based on OS). For Mac we use the Terminal app.
-
git: a command line tool for storing and managing changes made to files in a project (usually code)
-
Github: a web app that integrates with git and amplifies its functionality with a web-based interface and a social component
-
repository (repo): the place where the history of your work is stored (.git folder)
-
$: The dollar sign is commonly used to represent the command line. Anything to the right of it is what you enter (ex.
$ ls
means you enterls
) -
remote: stored on another computer (usually a server or Github)
-
commit: a single unit of changes to the project. Git works best when commits are small and frequent.
Local git repository consists of three “trees”:
-
working directory: where all of your files live in their current state
-
index (staging area): where your changes are staged before you commit them
-
git directory: where the history of all your changes live (.git folder)
project/ <-- working directory
├── home.html <-- files under version control
├── style.css
└── .git/ <-- git directory
pwd
- print the directory (folder) where you currently are
ls
- list all files in the current directory
ls -a
- list all files in the current directory including hidden files (beginning with a dot)
cd your-directory-here
- move to the specified directory
cd ..
- move to the parent directory (up one level)
mkdir new-directory-name
- make a new directory
rm file-name
- remove specified file (FOREVER! Be careful with this)
git init
- initialize the current directory to be version controlled by git
git config --global user.name your-username
- set your git username (the same as Github username)
git config --global user.email [email protected]
- set your git email (the same one you use for Github)
git log
- lists all of the commits in the repository, most recent ones first
git status
- provides information on current changes to your files, and whether those changes have been staged (added to the index)
Follow these steps to save your changes as a new version:
- stage your files (add them to the index)
$ git add -A .
- commit changes to files
$ git commit -m “brief description of changes”
- pull changes made by other people
$ git pull
- push your changes
$ git push