Introduction to Git
Thomas J. Kennedy
Git is a Version Control Platform that allows an individual or a team to track changes to a codebase. This includes maintaining records of what changes were, when changes were made, and by whom changes were made. This not only facilitates tracking progress.
Git allows one to:
- Explore alternative approaches.
- Reconcile conflicting changes (through
merge
). - Compare differences between branches and commits.
1 Learning to use Git
Basic git
usage is covered in CS252:
- SSH keys (required for interaction with GitHub)
- Version Control with git
- Now is the time to read the “optional” sections in the Appendix that you probably skipped in CS252.
2 Summary of Basic Commands
Before we can discuss merge and rebase, we must focus on the basic commands:
git init
- Initialize a repository (repo) in the current directorygit clone
- clone (i.e., copy) a remote repo.git add
- record files or changes to files.git rm
- remove one or more filesgit commit
andgit commit -m
- package together all staged changesgit push
- push (i.e., send) all local changes to a remote repo.git pull
- pull (i.e., retrieve) all changes from a remote repo.git log
- examine the commit history. This covered in a future section.
2.1 Getting Started
Let us focus on how each command is used in situ.
Let us start with a local repository (repo). Watch this recorded discussion.
This section will be expanded as we work through the next few lectures.