Write code (or other types of documents) with other people.
Mistakes happen. Wouldn't it be nice if you could see the changes that have been made and go back in time to fix something that went wrong?
Do you have files somewhere that look like this?
ResumeSeptember2019.docx
ResumeforDukeJob.docx
ResumeOLD.docx
ResumeNEW.docx
ResumeFINAL.docx
ResumeREALLYFINAL.docx
You invented your own version control!
To install git with Homebrew:
$ brew install gitSet your name and email in gitconfig
$ git config --global user.name "Captain Barnacles"
$ git config --global user.email "cb@octonauts.org"- Repository: A collection of files and their changes
- History: An ordered list of shapshots of changes in a repository over time
- Working Directory: The working copy of your files in your editor. These are also your unstaged changes.
- Staging area: A Git-specific concept: the way git designates a set of changes to be committed.
- Commit: One set or snapshot of changes
To get a local copy of a repo so you can work on it, you can run the following command, where <repo-url> is the url you copy from GitHub.
$ git clone <repo-url>This makes a local copy of a remote repo
After accepting the assignment in GitHub Classroom, you will see a link to your newly created repo. Click on this link. You'll see a repo like the one shown below. Click on the green button (starred in the image below) to display the window that has the url you need. Copy that url (highlighted in pink below).
git addgit commitgit push
- In a git repository, changes made in our editor (aka our working directory or working tree) need to be manually added to enter into the history
- The first time we add a new file, we tell Git to add the file to the repository to be tracked
- This is also called staging a file. A snapshot of our changes is ready to be saved in the next commit.
- A commit saves the changes made to a file, not the file as a whole. The commit will have a unique ID so we can track which changes were committed when and by whom.
- You push commits to the remote repo. Until you do this, the commits only exist locally.
git loggit diffgit status
- Accept the assignment invitation from GitHub Classroom.
- Clone the homework repo to your local environment (go to the repo on GitHub to grab the URL you'll need to clone the repo).
- Work on your homework in VS Code.
- Periodically add and commit your work to your local repo.
- When you are done, push your work to the remote repo.
- You can go to your repo on GitHub and see your commits there.
- add
- commit
- push
Follow these steps while you are working on your assignment and to turn in your work.
git add .git statusgit commit -m "Create content section"git statusgit push origin main



