Git For 61C
Git For 61C
Writing a Git guide is a bit like reinventing the wheel; there are dozens of great Git resources
available to you on the internet. Here are some I endorse:
● 61B’s Git tutorial, by Sarah Kim and Josh Hug; I did this as a student, and it has been
incredibly useful; it starts out from the very beginning and takes you through everything
you need to know, and I couldn’t recommend it highly enough.
● A git cheat sheet from Github with all the basic commands in one page.
● A git cheat sheet that has a great diagram that I highly recommend you look at.
● The Atlassian git tutorials are very complete, written to be fairly accessible to beginners,
and are full of great diagrams. If your goal is to understand what a command is doing,
this should be your first stop.
Please don’t hesitate to ask conceptual questions about Git. When I was a student in 61C it
seemed like everyone was a Git/command line wizard but me, but as a TA, I’ve discovered this
is absolutely not the case.
And if you have any suggestions for this guide, definitely let us know!
Part 1: Getting Started with detailed explanations
Step 3: Add the repository with the files you want to start out with as a remote
● A remote may exist on a website like Github or Bitbucket, or it may be a repository on a
machine that you have SSH access to
○ Command: git remote add [name of remote] [URL]
■ Usually: git remote add origin [URL], or git remote add
starter [URL]
git add
● Adds specified files to “staging area” so git tracks changes in them. Some options:
○ git add -A
■ Add all files
○ git add *.c
■ Add all .c files
○ git add foo.py
■ Add a particular file called foo.py
git commit
● Packages changes for tracked files into a “commit”, so it is officially in the history of your
local repository
○ git commit -m “Message”
■ Create a commit with the specified message
○ git commit -a -m “Message”
■ Does git add for all files and creates a commit with the specified
message
git push
● Sends all commits to a remote repository
○ git push
■ Pushes to the default upstream and branch. Usually, default upstream is
origin, but you can change this using the “--set-upstream” flag
○ git push origin master
○ git push [remote] [branch]
Part 2: Getting Started, with short descriptions
I have the files I want on Github, and I want them on a machine I’m working on
--OR--
--OR--
I have Git set up, I want to make some changes and push them so that they’re reflected
on Github
I want to get the starter files for class, make some changes, and push them to my
personal Github