- 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
- 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
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
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
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
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.
- 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
- Git Cheat Sheet
- Markdown Cheat Sheet
- VSCode for more convenient Markdown editing and simple Git operations
- GitHub Student Developer Pack for free stuff
- You can try using a more robust Git GUI Client if you want, but I find them to be a lot slower than the command line