You may be able to sympathize with revision and editing nightmares:
How might you solve this problem?
What if you overwrite something in the wrong directory? What if you need to keep track of many files that depend on each other? What if you want people to propose changes, but not make them?
Version control lets you offload the work of keeping track of everything related to a project, including documents, visualizations, and data.
You initialize it in a directory, and then tell it when you want your changes to be permanent.
You can go back to a previous iteration at any time, and can see exactly what has changed between versions. This is especially important for programming that uses plain text files and for programmers working together on packages.
gitGit is a distributed version control system. That means it can track, diff, and merge differences between the versions of a file on your system, and on any other system on this entire planet of Earth.
This makes it an enormously powerful tool for collaborative work.
GitHub is a website that hosts all of your Git repositories. It's good for keeping tabs on all the modified versions of your file everywhere it appears. While other social coding collaboratory sites exist (BitBucket, GitLab, etc.), GitHub is currently the most popular, and has the added advantage for students of free private repositories.
GitHub makes it very easy to download, modify, and share code. This sharing aspect is the main reason for us setting it up now. We want to see your work!
Let's go to GitHub and create an account. Use your Berkeley email address to register so you can get free private repos.
We'll also want to create a new repository of your own. A repository is basically a folder with all of its subfolders. Whatever you changes you make within that folder, Git can track.
Fill in the details to make a repository that will hold all your work for this course:
Click "Create repository!". Now you'll want the HTTPS URL:
Now we need to set up some things in the Terminal. You can open a Terminal in the Jupyter environment:
You'll then see something like this:
Let's run some setup commands:
git config --global user.name "henchc"
git config --global user.email "chench@berkeley.edu"
That's it! You shouldn't have to run these again now.
cd into your Repo:cd stands for "change directory". We need to move inside our folder so Git knows what we're talking about
cd REPO-NAME
Then we need to add a remote for this repository, the remote is the URL you copied to our clipboard from above:
git remote -v
git remote add my-repo https://github.com/USERNAME/REPO-NAME
Great, now your folder here can communicate with your folder on GitHub. But you'll still have to tell it each time you want to add changes to the online version.
Now that you're all set up, you should only ever have to run the three commands below (after you cd into your folder).
git add -A # this prepares everything for the snapshot
git commit -m 'made these changes' # this takes the snapshot and makes a comment about it
git push my-repo # this pushes your changes to your GitHub repo!
Congrats! You've pushed your first changes to GitHub! Check out your GitHub account now and see what's there.
Please send me your repository URL via this Google Form. Then I can write a script to collect your updates and look at your projects and assignments.