Quick start for using Git

Project maintained by HackBinghamton Hosted on GitHub Pages — Theme by mattgraham

Git Tutorial

Getting ready


Install git using your package manager eg. sudo apt install git.


Open a terminal and type git. If you get a prompt to install xcode command line tools, let it install. If you're impatient or want the latest version, you can install Git with this download You may need to follow this guide if you use the second option.


You'll have to download Git and a Terminal from here.

Why Git?

What can I store in Git?

Short answer: anything!

Longer answer: Anything that is in a plain-text format (source code, text files, html) can be tracked by Git very well. Binary files also can be tracked, but you shouldn't put certain binary files into Git. You shouldn't add generated executable files and object-code (.class, .pyc) because those files can be built using the source code. Images are generally okay to add, GitHub will even show the differences in images!

So, how do I use it?

Configure git

We need to tell git who you are first. Type git config --global "" to set your email. Then type git config --global "Johnny Hacker" to set your name.

Make a project

In your terminal type mkdir myproject and cd myproject to create and enter a project directory.

To make your current directory a git repository, just type git init.

Now that you have a directory with git, you can use the directory just like any other directory. Write or copy some files into the directory, and then type git status. This will show you the current status of what's available to add to Git. Under untracked files, you'll see the files that are in the directory, but not stored in Git.

Saving changes

To start tracking a file, type git add myfile.txt. This hasn't saved the changes yet because we need to ask git to do that first. Add any other files with git add otherfile.txt coolpicture.jpg etc..

When you're ready to save your changes, type git status to review what's going to be saved. If it all looks good, type git commit -m "Write something descriptive here".

To see what was saved, type git show. If you want to see a log of all of your previous commits, type git log.

What about GitHub?

Now that you have a git repository on your computer, you might want to back it up somewhere safe. By uploading your git repository to GitHub, you'll let other people see what you're working on and allow others to help you make an awesome project. You'll need a GitHub account to do this. Make sure you use the same email that you configured git with when you join.

Make the repository

New Repository

Give it an interesting title

Create Repository

Make sure Initialize this repository is unchecked! Since you already made the repo locally, we want to start with an empty repo.

Follow the instructions

Push Repository

You'll be prompted for your GitHub username and password so that they know it's you. After running git push -u origin master, your code should be on GitHub! If you make more changes, you can run git push after committing your files to send the changes to GitHub.