Git #
Version control systems are used in managing revision control of project artifacts, and maintaining a history of changes to each artifact. Artifacts can include documents, source code, and much more.
Motivations for Source Version Control
- Keeping track of code
- Storing versions of code changes
- Restoring previous versions
- Reviewing work history
- Collaborating in a group
- Backup
- There are two main approaches to version control management systems. That is, they can either be centralized, or decentralized repositories. This page covers Git is a decentralized system.
Terminology #
Git vs GitHub #
Git — The version control tool that GitHub is built on top of. You do not need GitHub to use Git. You can install git to your machine to use locally.
GitHub is a hosting service using git the open source revision control system. Github’s service allows you to share your code with the world, and also has several other collaboration features.
Common Git Commands #
Some common workflow steps
Command | Description |
---|---|
git add |
puts changes to the stage |
git commit |
logs the staged |
git push origin master |
uploads the local master branch to server |
Other common commands
Command | Description |
---|---|
git pull |
downloads latest version from server |
git fetch |
checks for changes but doesn’t download it |
git clone <address> |
copies a server verion to local machine |
git remote -v |
shows the server address |
Workspace and Commits #
- Workspace - this is where you have files you’re editing in a folder
- Stage - this is where you put files or selected lines into an area to be given a commit message
- Commit Log - a history of committed changes.
Slides #
Workflow for “syncing” your local and remote repos #
The first time you copy from the server, you are cloning the repository. Once you have a local copy, getting more updates is considered a pull.
When you make edits on your local machine, you save snapshots or revisions to your commit log. When you’re done for the day, you can push or upload changes back to ther remote.
Suggested reading #
-
Read Chapters 1-2 of the git book: https://git-scm.com/book/en/v2
-
Creating a new repository on GitHub https://help.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-new-repository