CSE 102 Git Instructions
CSE 102 Git Instructions
assignment. Here I will show you how you can install Git to your computer and how you can use it. This
will be a very basic introduction to Git. I will only talk about what you need to do for assignments. You
can find more information about how to install and use it online.
Some links:
W3Schools: https://www.w3schools.com/git/
Let’s start with what Git is. It is a version control system that helps you keep track of code changes. It is
created by legendary Linus Torvalds. Git has a GUI, but I would like you to learn using git through the
terminal. Git is different from GitHub. Latter one is a remote repository platform that allows
programmers to collaboratively work on code.
Git manages projects with Repositories. You can Clone a project to work on a local copy. Control and
track changes with Staging and Committing. Branch and Merge allow you to work on different parts and
versions of a project. Pull the latest version of the project to a local copy and Push local updates to the
main project. Here, I will not go into details, but I highly recommend you check out the links. The
purpose of this text is to mention important and very basic things you should do for each assignment.
Initializing Git on a folder, makes it a Repository. Git automatically creates a hidden folder to keep track
of changes in that folder. The hidden folder’s name is “.git” without quotations. When a file is changed,
added or deleted, it is considered as modified. You select the modified files you want to Stage, basically
they are getting prepared for Committing. Committing files prompts Git to store a permanent snapshot
of the files. You view the history of every commit through these snapshots. You can even revert back to
any previous commit. Git does not store a separate copy of every file in every commit but keeps track of
changes made in each commit.
After installing the Git, you need to let Git know who you are. To do this you need to open a terminal and
type:
For every assignment, you will go to source folder for your code(Where your java file(s) are) and either
through Command prompt(you can just click to part where it shows you the path information of the
folder and type cmd then press enter) or through Git Bash(you can just right click anywhere in the folder
and select Git Bash) open a terminal screen and you will type:
git add .
Instead of dot(.) you can specify a file name. If you use the dot(.), Git will stage all files in the current
directory with changes, deletions or new entries for committing. To check which files are going to be
committed you type:
git status
This will show you what operations are made to each file. Don’t forget to add files to Staging because
otherwise you can’t commit these changes. It is always good to make your commits with a one-line,
short comment sentence that describes the commit. To commit the staged files you will type:
Committing often but not excessively is the key of committing changes to your repository. You are not
required or limited for committing only when you have written a class. Instead, you usually commit when
you did a unit of work. Again, what a unit of work can change depending on a project and can vary from
one project to other.
DO NOT FORGET TO COMMIT YOUR CHANGES. It is important for us to see your assignments progress.
You will need to upload your Git repository along side of your java file. When uploading to turn in your
assignments. YOU NEED TO UPLOAD THAT GIT FOLDER TOO.
That “.git” folder may be hidden and you may not be able to see it inside of your folder. In that case, you
will need to make a quick google search to figure out how to show hidden folders.
In short, create a Git repository where your source code(java files will be). Commit the unit of works you
do throughout the assignment. Turn in your “.git” folder alongside of your java source file.
INITIALIZING A GIT REPOSITORY MUST BE THE FIRST THING YOU SHOULD DO WHEN YOU START
WORKING ON AN ASSIGNMENT. I also recommend you to commit not so long after initializing the
repository.
Lastly, don’t forget to check the links or other sources you find online to learn Git. It might be the most
important tool you will ever learn throughout your software career.