Skip to content

Latest commit

 

History

History
110 lines (86 loc) · 3.18 KB

instructions.md

File metadata and controls

110 lines (86 loc) · 3.18 KB

Git Instructions

Motivation for Version Control

  • Track changes in complex code
  • Share code efficiently with others
  • Keep track of who contributes what to code
  • Be able to rollback changes that create problems

Basics of a Repository

  • Fundamentally a folder on your computer
  • Every file in it is either "tracked" or "ignored"
  • When changes are made in "tracked" files, the user will "commit" them to the repository
  • Committed changes can then be "pushed" to a remote repository (GitHub)
  • Changes pushed by others to the remote repository can be "pulled" to the user's local repository
  • If multiple things are being developed in parallel, a repository can be split into multiple branches which can be worked on independently

Install Git

Open the "Terminal" program on your computer and run the command:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Once Homebrew has installed, run the command:

brew install git

Clone a Repository

In the terminal, run the command:

mkdir ~/Desktop/git-tutorial

then

cd ~/Desktop/git-tutorial

and finally

git clone https://github.com/DaanielC/git-tutorial.git

Create Your Own Repository

First, create a new directory to store your project in:

mkdir ~/Desktop/first-repo

and go into that folder:

cd ~/Desktop/first-repo

Then create a readme.md file. An easy way to start this quickly is:

echo "# first-repo" >> readme.md

Then initialize the Git repository:

git init

Add readme.md as a tracked file in the repository:

git add readme.md

And commit the change to readme.md with a message:

git commit -m "first commit"

Finally, define which branch you are working on:

git branch -M main

Push Changes to GitHub

Go to GitHub and create an account. It is probably best to sign up with an email address that you will continue to use for a long time, but you can also link your Rowland Hall email address later to get a bunch of professional software for free.

Once you have created your account create a new project called "first-repo"

Back in your command line, run

git remote add origin https://github.com/[Your User Name]/first-repo.git

and substitute in your GitHub user name.

Then run

git push -u origin main

When you refresh the page for your repository on GitHub, you should see that your readme.md file has been added.

Practice

  • Clone Dr. Kuntz' machine learning repository and try to run one of the scripts in your MATLAB
  • Put your code so far into a Git repository with a readme.md and push it to a repository on your personal GitHub

Additional Resources