Git Repository Tutorial Windows 7 Using Git Bash

The first assignment for ECS 40 was to setup and use a Git repository.  This is very useful as a repository will allow you to see changes to your code throughout the development process and it will save versions of the code all along the way.

This tutorial is the first assignment for Homework 0 for professor Hao Chen.  As I am currently using a Windows 7 install, this tutorial will only be for the windows people.

To begin you must first download Git Bash for windows from the following link.   http://code.google.com/p/msysgit/

The newest version should be on top (and the biggest file size)

After you download and install the program using the tutorial http://help.github.com/win-git-installation/ here (WARNING, this tutorial is slightly out of date and the 7th slide labeled “Choosing CR/LF Behavior” is considerably different.  Choose the middle one if you want to still have the same result though).  Now you should have the following Git Bash icon on your desktop as well as a folder in your users/login directory on your computer named .ssh as shown below.

Notice the location of the .ssh and the application icon!

Now there is a difficult step.  You must get a password for your repository.  Our teacher emailed us the passwords and we put them in the .ssh folder.  However, when we start the Git Bash program, our root directory will be one above this (so for me it would be Theiss).  In order to go up a directory type         cd ~/.ssh and that will bring you into the appropriate directory.  For us, we now edit a config file using the command vim config .  Type     i to insert text and then type the following two lines.

Host emu.cs.ucdavis.edu
IdentityFile ~/.ssh/username.ecs40

After that, press    esc and type    :wq (to Write the file an Quit).  Then hit enter again.

Now  change the permissions on your root directory with the chmod 700 ~/.ssh   . Your screen should look like something below.

After that you can easily grab and update repository files.  To grab a copy (or clone), type git clone git@emu.cs.ucdavis.edu:hw0-username and it should grab the files as shown below.

If it does not do this and asks for a password, you did not put your password files in the .ssh directory that was created (and there is a picture of above).

Lastly, to edit the repository files and submit them back, you have to go into the directory of the clone you created.  Type cd hw0-username which will bring you to the folder with your files.  Edit any of the files using vi filename .   Then type git add . followed by git commit -a and the a window will come up with a note to add.   Type the note and type a :wq again and then type git push.  If you are successful, it should look like the last picture I posted.

Since I didnt change my file this time around, it gives my an “up to date” response and doesn’t ask for more comments. Yours should have a few extra lines saying it uploaded some files.

Hope this helps!

Tags: , , , ,

Comments are closed.