Professional Documents
Culture Documents
Git Tutorial by Dhruv Jain
Git Tutorial by Dhruv Jain
Git Tutorial by Dhruv Jain
Git tutorial
by Dhruv Jain
What is git?
What is git?
Git is a widely used version control system for software
development. It is a distributed revision control system with an
Installing emphasis on speed, data integrity, and support for distributed,
non-linear workflows. Git was initially designed and developed
git by Linus Torvalds for Linux kernel development in 2005 [1].
For those of you who don't know the basis of version control,
Setup refer to this video to learn about the basis:
computer
Clone class
archive
Pulling from
server
Adding and
Committing
Pushing to
For those of you who know the basis of version control but want
server a quick introduction to git:
Useful tips
http://fab.cba.mit.edu/classes/863.15/doc/tutorials/version_control/index.html Page 1 of 7
Git tutorial by Dhruv Jain 3/15/17, 5(52 PM
Installing Git
Linux
If you want to install Git on Linux via a binary installer, you
can generally do so through the basic package-management tool
that comes with your distribution. If youre on Fedora for
example, you can use yum:
Mac
There are several ways to install Git on a Mac. The easiest is
probably to install the Xcode Command Line Tools. On Mavericks
(10.9) or above you can do this simply by trying to run git from
the Terminal the very first time. If you dont have it installed
already, it will prompt you to install it.
You can also install it as part of the GitHub for Mac install.
http://fab.cba.mit.edu/classes/863.15/doc/tutorials/version_control/index.html Page 2 of 7
Git tutorial by Dhruv Jain 3/15/17, 5(52 PM
Their GUI Git tool has an option to install command line tools
as well. You can download that tool from the GitHub for Mac
website.
Windows
There are also a few ways to install Git on Windows. The most
official build is available for download on the Git website.
Note that this is a project called Git for Windows, which is
separate from Git itself.
$ ls ~/.ssh/keys
$ mkdir ~/.ssh/keys
Now that we have the folder created, copy the archive keys
you're going to use into the folder. You can do this in many
different ways. The simplest is probably to open a finder window
and drag and drop the key files into the folder. Because folders
that start with a . are hidden folders on UNIX operating
systems, you can use the command line to open the finder to the
correct location:
$ open ~/.ssh/keys
http://fab.cba.mit.edu/classes/863.15/doc/tutorials/version_control/index.html Page 3 of 7
Git tutorial by Dhruv Jain 3/15/17, 5(52 PM
Alternatively, you can use the copy command to copy the correct
files. Remember you can use wildcards like * to copy multiple
files at once
$ ls -la ~/.ssh/keys
$ -rwxr-xr-x
$ -rw-------
http://fab.cba.mit.edu/classes/863.15/doc/tutorials/version_control/index.html Page 4 of 7
Git tutorial by Dhruv Jain 3/15/17, 5(52 PM
a file config in .ssh folder, and copy the following code (make
sure the code is correctly indented, otherwise it won't work).
host fabclasses
hostname fab.cba.mit.edu
user git
user git
port 846
identityfile ~/.ssh/keys/classes
Let's clone our repo now. Open the terminal (git bash on
Windows), navigate to the folder where you want to clone your
repo, and type one of the following commands based on the
section you're in:
git pull
This eliminates the most common merge, which is two people doing
unrelated development on the same branch.
git status
This would give you the breif summary of the situation and will
tell you which changes are unstaged, and which files are ready
to be commmitted etc.
Adding files
In this case, I recently created this index.html page, and want
to include it in the next commit. To do that, I use the command
below:
Re-running the status command should now show that the file will
be added to the next commit:
Changes to be committed:
modified: index.html
If I wanted to add all the files that I've changed in one go, I
can use the command:
git add -A
Changes to be committed:
modified: index.html
modified: about.html
Committing
Once you have selected the files that should go into your
commit, you can commit your version by using the following
command:
http://fab.cba.mit.edu/classes/863.15/doc/tutorials/version_control/index.html Page 6 of 7
Git tutorial by Dhruv Jain 3/15/17, 5(52 PM
Merging
Merging occurs when you have two parrallel branches of
development that need to be unified. This often happens when you
have been offline (aka haven't pulled and updated your archive)
in a while and changes have been made in parallel. Sometimes,
these changes will conflict with eachother and you will need to
actively choose which changes to keep and which you throw.
git merge
git push
Useful tips
For an extensive tutorial on git, my recommendation is git-
scm.com.
References
1. Git (software). Wikipedia, the free encyclopedia. Accessed
Oct 2015
2. VSC Tutorial. Charles Fracchia, MAS863.14. Accessed Oct
2015
http://fab.cba.mit.edu/classes/863.15/doc/tutorials/version_control/index.html Page 7 of 7