By contrast, what you did in CMSC 201, using SSH to connect to a Linux server (GL) where you would edit and run your files is called remote development.
Remote VS. |
Local |
---|---|
Pro: Everything is installed for you by the administrator. | Con: It's up to you to learn to install and configure what you need to run your code. |
Pro: Backups are handled for you. | Con: You're responsible for backups. |
Pro: ...but a VCS provides powerful ways to backup & share code once you learn it (more on that later...) | |
Con: You can't develop without an internet connection | Pro: You can develop with no or slow internet |
Con: Using emacs over SSH is a primitive, painstaking, slow way to program | Pro: You have and incredibly rich set of tools to help you write code. |
Pro: you can configure your development environment however you like | |
Con: you can configure your development environment however you like |
Purpose | Windows | Mac or Linux |
---|---|---|
Get help |
|
|
Show current directory |
|
|
Change directory |
|
|
Show files in directory |
|
|
Create a new directory |
|
|
Delete a directory |
|
|
Purpose | Windows | Mac & Linux |
---|---|---|
Show total file content |
|
|
Page through file contents |
|
|
Create a new file |
|
|
Add to a file |
|
|
Rename/Move a file |
|
|
Copy a file |
|
|
Purpose | Windows | Mac | Linux |
---|---|---|---|
Python (check version) |
|
|
|
Python (interactive shell or REPL) |
|
|
|
Running a Python script |
|
|
|
What are they? What are they good for?
A version control system (VCS) is...
A VCS is good for...
“The information manager from hell”
— Linus Torvalds
repository/repo: a database containing all the information needed to retain and manage the revisions and history of a project (this is hidden in .git/objects
, don't touch!)
hash: a unique identifier for each and every version of an object Git tracks.
Example: 9da581d910c9c4ac93557ca4859e767f5caf5169
.
The hash is generated from the contents of a file, because Git tracks file content, not file names
commit: a set of one or more changes to your repo that are grouped together and uniquely identified. Think of it like a snapshot you take of your project that is saved forever or like a save point in a video game.
Each commit will also have its own hash. The user, commit date, and an optional comment will be stored in the repo as well.
head: the latest commit in your history
branch: a way of launching a separate line of development within a project. Think of it as an alternate timeline, but you can merge it back to the original
master/main: every project has at least one branch, and it's this one. Think of it as the "original" timeline and you can branch and rejoin it as many times as you want
remote/origin: a clone of your repo that exists on some other machine
clone: a copy of a repository. A clone contains all the objects from the original, meaning the whole history of the repo is contained in every clone
working copy/working directory: a clone of your repo that exists on your machine. You do your work—creating, editing or removing files and folders—in the working directory
push: push your commit(s) from your working copy to a remote
pull: pull someone else's commit(s) from a remote to your working copy
staging area: part of the repository that stores information about what will go into your next commit
In git you have to stage files before you commit them.
Think of git-add
as being like writing in pencil. git commit
is like writing in pen.
git init
) or clone an existing one (git clone
).git add
)git commit
)git push
)Some files you don't want to version (like .pyc
files, editor/IDE config, etc).
Create a .gitignore
file in the root of you project to tell Git which files it should ignore:
*.pyc
.DS_Store
.idea/
Git and GitHub: software engineering's power couple.