GitHub is an interface built on Git, a version control system you can use right from the command line. GitHub allows you to store code and make changes to an online repository. This enables you to easily update your code as well as collaborate with others by sharing a common repository. We will be using GitHub Classroom to distribute all of the stencil code for assignments, which you can access from the course website. Let’s learn a little more about GitHub and Git!
You can sign up for an account here and get the GitHub Student Pack with your Brown email for more tools and features.
Below are some common Git commands to get you started!
git clone [URL-or-path-to-repo]
- Retrieve an entire repository from a hosted location via URL to your local machinegit status
- Display the state of the current repository. Use this to see your tracked files, untracked files and changes.git add [file]
- Add the given file to the repository. Use this when you create a new file and want to include it in a commit. Alternatively, include [-a]
to add all files from your local repogit commit -m [some message]
- Commit your code to finalize and save changes to your current branch and repo on your local machine.[-a]
to automatically add changed files that git is already tracking and [-m “[some message]”]
to include a message about the commit (otherwise you will be kicked to an editor in which to type out your message).git push
- Push whatever commits you have made locally to the repository you cloned from to save your changes to the online repo. (You might have to pull first to sync with the remote repository)git pull
- Pull any changes from the remote repository you cloned from.If you prefer GUIs we recommend using GitHub Desktop, this gives you a great visual way of interacting with GitHub. It allows you to better visualize your code changes when you commit and push, and helps prevent committing files that you don't want to be stored in your repo.
You can download Github Desktop for your platform here, and follow the setup guide here.
You will use GitHub Classroom in this course. All assignments and stencil code will be available through an assignment link on the webpage. Once you click on the link this is what you should see:
After clicking the button, GitHub will create a repository unique to you and after everything loads, you should see this page:
After clicking on the link, it will navigate you directly to your own private repository with the stencil code already in the repository.
Now you have your own personal repository for the project! You can preview the files on this webpage, but in order to change them and actually work on the assignment, you should download them to your computer using the following instructions.
Click on the Code
button and you will see:
To download the files to your computer, you have 2 options:
git clone [URL]
Now that you have a folder with the template code on your personal machine, you can edit those files. Once you're ready to save or backup your changes, you can follow these steps:
cd
into the project directory.git add --a
git add [PATH_TO_FILE]
git commit --m "[SOME_MESSAGE]"
git push
Remember to commit often to save a record of your code and push to the remote repository to save it on GitHub as well.
Note: You may need to create a GitHub Personal Access Token to clone using the command-line interface.