GIT SETUP

You have to follow the pdf file to create git and use the terminal. Elvis means terminal you got a put simsek78@elvis.rowan.edu and it’s gonna ask you a password, I’ll give you it letter

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

git allows users to track changes to a project and share their project files. Multiple people can
work at the same time without stomping each other’s work.
For this tutorial, I created a file, and put it in a local repository which only I have access to.
(This corresponds to steps 1-3 in the file ‘GitOutline.pdf’ in this same folder.)
Then, for each student, I pushed the repository to a shared location, where you can get to it.
(That corresponds to steps 4-5 in the ‘GitOutline.pdf’ file.)
This tutorial will show you how to get your own copy of a project, make changes, and then send
your work back to the central repository. (Steps 6-8 in ‘GitOutline.pdf’.)
Here is what will be covered:
1. Setting up git before first use,
2. cloning your own copy of the git repository from the shared location,
3. making basic changes in a text editor,
4. committing your changes to your local repository,
Computer Lab Techniques: GIT Tutorial
Git Tutorial
5. tagging the version you want me to see,
6. pushing your changes and tags back to the shared location,
7. updating file permissions on the shared repository (required due to Elvis security settings).
8. how to turn in your work for grading
Log on to Elvis to get started. It’s probably best to have the terminal window on one side of your
screen and this PDF on the other.
1
Setting up git
1.1
Setting Your Name and Email Address
Different companies do things different ways; the ‘initial and last name’ format is pretty common.
Page 1 of 11
If you haven’t used git on Elvis, it’ll guess at your name and email address. It may guess wrong.
To stop that, you can set it up with these commands, but of course type your name and email
address, not Bruce Wayne’s.
git config –global user.name ‘B Wayne’
git config –global user.email ‘batman@students.rowan.edu’
Note: you can use either single or double quotes, but they have to match. If you have an apostrophe
in your name, such as O’Toole, will want double quotes, like this:
git config –global user.name “P O’Toole Wayne”
This works fine, but the closing quote has to be the same as the opening quote. You can’t pair
‘ and “.
Computer Lab Techniques: GIT Tutorial
1.2
Telling Git You’ll Be Working With Others
By default, git will complain if you try to clone from a folder that belongs to someone else. In this
class, you’ll be working with other people, so we need to tell git that you expect to be doing that.
git config –global –add safe.directory ‘*’
1.3
Setting The Default Branch to ‘main’
By default, git uses ‘master’, a word with some problematic history, for the name of the primary
version of a project.
For this class, we will be using ‘main’, which you can set with this command:
git config –global init.defaultBranch main
1.4
Checking Your Settings
To see the default settings, you can run:
git config -l (that’s an ell, not a one; ‘l’ as in ‘list’).
Here’s what I get when I run that:
elvix2:˜ 11> git config -l
user.name=D Provine
user.email=kilroy@rowan.edu
init.defaultbranch=main
safe.directory=’*’
elvix2:˜ 12>
If your settings look right, go on to the next step.
If something looks wrong, you can use the up arrow on your keyboard to go back to the previous
commands, use the left and right arrows to find the problem, use the backspace key to erase
whatever’s wrong, and type in your corrections.
2
Cloning Your Own Copy Of A Repository
Cloning makes a local copy of a shared repository from some central location. Run the following
command (where it has ‘batman’ in the box, use your Rowan network username):
git clone /opt/cs/kilroy/GIT/ batman /GitInfo
Page 2 of 11
You will now have a new folder, named GitInfo. Go into it by typing:
You can see the file in there by running:
ls
The file you have now is an exact copy of the file as originally created.
You can look to see what’s inside by running this:
cat AboutMe.txt .
cd GitInfo
Making Changes With A Text Editor
3.1
Unix Editors
Elvis has a number of text editors installed. Most users prefer Emacs or vim, which have many
features: automatic indentation, parenthesis matching, syntax highlighting, &c. (There are simpler
editors, such as pico and nano, which can be learned quickly, because they don’t have many
features.) Many students print out a cheat sheet and keep it nearby. After a few days they’ve
learned the commands they need and don’t have to refer to the cheat sheet again.
3.2
Emacs
If you are already familiar with Unix editors, especially vim, or if you just want to try one of the
others, feel free to use a different one and skip this section.
3.2.1
Notation and keystrokes
1. The notation ‘ˆX’ means to type control-X, not ‘type a caret followed by an X’.
Computer Lab Techniques: GIT Tutorial
3
2. Emacs has thousands of commands, and you have to be careful about keystrokes.
ˆS will search forward.
ˆXˆS will save your file.
ˆXˆXˆS will be interpreted as two commands:
ˆXˆX : swap the cursor position with a previous point.
ˆS : search forward.
3.2.2
Backspace and Delete
One possible snag is that ˆH (control-H) may open the Help screen. Some keyboards send ˆH for
delete, so you may try to fix a mistake and start help mode. (To get out of help, type ˆG.)
If you are using SecureCRT, you can choose the
‘Options’ menu, and select ‘Session Options’.
Work down the tree to
Terminal → Emulation → Mapped Keys
You’ll get a window that looks like this ⇒
Page 3 of 11
One of checkboxes is ‘Backspace sends delete’.
Turn that on, and you won’t accidentally get the
help window in Emacs.
Computer Lab Techniques: GIT Tutorial
3.3
Modifying The ‘AboutMe.txt’ File
For this tutorial, only one file that needs to be changed, and all that’s necessary is basic typing.
Here’s how the file will look after you clone it:
Here’s how Abed Nadir might fill his in:
Stuff About Me!
Stuff About Me!
Short-answer:
Short-answer:
1) First name:
Official:
Preferred:
1) First name:
Official: Abed
Preferred: (same)
2) Last name:
Official:
Preferred:
2) Last name:
Official: Nadir (rhymes with ‘beer’)
Preferred: (same)
3) Pronouns:
3) Pronouns: he/him/his
4) Title:
4) Title: Mr.
5) Salutation:
5) Salutation: Mr. Nadir
Longer-answer:
Longer-answer:
6) Favorite thing about Computer Science:
6) Favorite thing about Computer Science:
7) Most irritating thing about being a CS major:
8) A movie Professor Provine should watch is:
9) A book Professor Provine should read is:
Writing custom mods for video editing.
7) Most irritating thing about being a CS major:
It’s hard. (But I suppose if it were easy,
it would pay minimum wage.)
8) A movie Professor Provine should watch is:
Kickpuncher
9) A book Professor Provine should read is:
Inspector Spacetime and the Crying Statues
The salutation is how you would be referred to at the start of a formal letter, such as ‘Dear Mr. Nadir,’
for a letter to Abed.
Page 4 of 11
Similar formality is used in letters of recommendation:
‘Mx. Thorne served as shipmaster in the Dendarii Free Mercenaries for ten years.’
‘Ms. Frye’s mechanical abilities are equal to the best of anyone you might hire.’
Or when introducing a speaker:
‘Mrs. Fields will now present her research on cookies.’
‘Captain Naismith will share highlights from the biological survey of Sergyar.’
‘Dr. Seuss will be describing species encountered on the Great Barrier Reef.’
‘Dr. Tinkham will read original poetry about her awesome husband.’
Running Emacs
To run Emacs on your file, type: emacs -nw AboutMe.txt
make its own window, but to use the one you’re already in.)
(The -nw flag tells Emacs not to
Here’s what I get:
Computer Lab Techniques: GIT Tutorial
3.3.1
You can access the menu bar at the top with the F10; if your laptop uses that to adjust volume or
brightness you may need to press other keys first. I don’t know how your laptop is set up, so for
this tutorial we won’t use the menu.
Along the bottom there is a status line, giving the name of the file, what part you’re looking at
(I’m at the top), and where the cursor is (1, 0). Emacs can tell that this file is tracked with git
and is a plain text file (as opposed to Java source code or HTML or something.) If your window is
big enough to see the whole file at once, instead of ‘Top’ it will say ‘All’.
The very bottom line is used for messages in case the editor thinks you need to know something.
Once the editor has started, you can move around with the arrow keys.
So, for example, you can downarrow until you get to the line for your official first name.
(Notice that it keeps the line number continually updated.)
To get to the end of the line, type ˆE (control-E), and the cursor will jump to the end of the line.
Then you type your official name as it appears in University records.
You can continue moving down to fill in your last name, your pronouns, and how you would be
correctly referred to in a formal setting. Most students go with ‘Mr.’ or ‘Ms.’, but some have
preferred ‘Mx.’, ‘Mrs.’, or some other honorific.
Page 5 of 11
Hit the downarrow, and you can put in your preferred first name, or you can just type ‘(same)’.
Computer Lab Techniques: GIT Tutorial
When you get to the bottom of the window, Emacs will scroll the document.
The status line will no longer say ‘Top’, but instead will show a percentage, indicating how far you
are down in the file.
(If you change the size of the window, Emacs will update automatically, so you can experiment to
see how scrolling works if you like.)
For the long answer section, you can use the enter/return key to insert lines.
Here’s what mine looks like after I’m done typing:
Notice that the status bar has two asterisks in it, which means I have unsaved changes. It’s also
telling me that my position in the file is ‘Bot’, because I’m at the bottom.
You can use the up arrow key to review your file. When you finish, save by typing ˆXˆS.
(Note that the two asterisks go away, because there are no unsaved changes.)
To quit, type ˆXˆC.
3.4
Double-Checking What You’ve Done
Page 6 of 11
To see what is in the file after you finish, you can run ‘cat’ again: cat AboutMe.txt
(Remember you can just press the uparrow at a shell prompt to re-run a previous command.)
If the file looks okay, go to the next step.
If something is wrong, you can run Emacs again (using the uparrow if you like) and make more
changes. Then run ‘cat’ again to verify the file is correct. (You can have as many edit/verify cycles
as you like; the computer won’t get bored.)
Here’s what Natasha Romanoff might write:
Stuff About Me!
Stuff About Me!
Short-answer:
Short-answer:
1) First name:
Official: Darren
Preferred: (same)
1) First name:
Official: Natasha
Preferred: Nat
2) Last name:
Official: Provine
Preferred: (same)
2) Last name:
Official: Romanoff
Preferred: (same)
3) Pronouns: he/him/his
3) Pronouns: she/her/hers
4) Title: Professor
4) Title: Ms.
5) Salutation: Prof. Provine
5) Salutation: Ms. Romanoff
Longer-answer:
Longer-answer:
6) Favorite thing about Computer Science:
6) Favorite thing about Computer Science:
Solving problems and making programs run.
7) Most irritating thing about being a CS major:
Debugging my own code.
8) A movie Professor Provine should watch is:
Memento
9) A book Professor Provine should read is:
The Spirit Ring, by Lois McMaster Bujold
Learning to break into systems.
Computer Lab Techniques: GIT Tutorial
Here’s my file:
7) Most irritating thing about being a CS major:
Getting hit on by classmates.
8) A movie Professor Provine should watch is:
Black Widow
9) A book Professor Provine should read is:
Charlotte’s Web
Ms. Romanoff and I are both happy with how ours look, so we go on to the next step.
4
Committing your changes
When you’re working, you generally don’t want to save intermediate stages. Maybe you added a
new parameter to some function, you have to update the function calls for the program to work.
Git does not save every keystroke, or save every file, you have to tell it when you want it to save.
After you get the files to a version you want added to the repository, you commit those changes. A
commit is like a snapshot of every file currently being tracked.
A commit should (a) specify which files to include, and (b) have a brief summary of what was done.
git commit -a -m ‘Filled in with my information.’
(‘-a’ here means to include all changed files; ‘-m’ says this is the log message.)
Page 7 of 11
The easiest way to do both things is using command flags. For this tutorial, after you have the
‘AboutMe.txt’ file the way you want it, you should run this command:
Computer Lab Techniques: GIT Tutorial
Here’s what I get when I run that command:
[main f4f1afb] Filled in with my information.
1 file changed, 12 insertions(+), 11 deletions(-)
One file was changed, 12 lines were added, replacing 11 deleted lines. (If you change a line, git
considers that deleting the line and replacing it with a new one.) The numbers are different because
I hit return after the name of the book, adding a blank line. (You can see the cursor down one line
in the screenshot on page 5.)
5
Tagging your commit
Git uses a 40-character string to identify a commit. You can see it by running
git log
Depending on your terminal color settings, the output may be hard to read.
You can turn off color highlighting with the ‘–no-color’ flag: git log –no-color
Here’s my output:
commit f4f1afb3139f25ceaec390075e21e909b065169b (HEAD -> main)
Author: D Provine
Date:
Wed Sep 4 18:09:03 2024 -0400
Filled in with my information.
commit ee3a5a874ebb9b99609131a9ee02d45821594f39 (tag: initial, origin/main, origin/HEAD)
Author: D Provine
Date:
Wed Sep 4 17:56:37 2024 -0400
Initial Revision
The commit I made is ‘ee3a5a874ebb9b99609131a9ee02d45821594f39’; yours is probably different.
Such long names are awkward, so you can tag a commit with a shorter name.
A commit is like a snapshot of all the files; a tag refers to a particular snapshot. In general, you
usually commit before you tag.
For class assignments (such as this one), I will give you a tag to use for grading. You may have
other commits, for bugs you found after, or because you started Part 2 before I graded Part 1. All
of that is fine, because I will grade the tagged version. Earlier or later versions won’t matter.
For this assignment, the tag should be finished (tags are case-sensitive; use all-lowercase).
Page 8 of 11
When tagging, give the tag name and a short message. As with commit, you can do both on the
same line with some flags. For this assignment, after you have finished and have committed your
changes, run this command:
git tag -a finished -m ‘Ready to grade.’
(‘-a’ means annotate; ‘-m’ says this is the message.)
Git doesn’t print anything here unless something goes wrong.
Pushing your changes
Right now, all the work you’ve done is only in your folder. (We’re up to Step 7 in the git outline;
where Bob has made changes.) For me to see your work, you need to send your updates to the
shared repository (Step 8 in the outline).
By default, git keeps your tags only in your space. But since I want to use them too, you will need
to tell git about that.
Run this command:
git push –follow-tags
(‘–follow-tags’ tells git to send the tags up along with the changes.)
Here’s what I get:
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 391 bytes | 391.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
To /opt/cs/kilroy/GIT/kilroy/GitInfo/
f4f1afb..ee3a5a8 main -> main
Computer Lab Techniques: GIT Tutorial
6
The last line has the first seven digits of the initial commit, then two dots, then the first seven
digits of my commit, showing that git has updated the main one with my changes.
7
Updating Unix File Permissions
Elvis is configured so that any new files you create are locked down, even when that is not necessary.
To fix this, you can run the command:
/opt/cs/bin/fix_git
(That’s an underscore, not a period.)
This will fix the permissions on all your git repositories for all your professors.
8
Turning In Your Work
8.1
How Programs Are Graded
To grade your work, I have to get the latest version from the git repository.
(This corresponds to steps 9-11 on the GitOutline.pdf file.)
/opt/cs/bin/grade_program kilroy GitInfo batman
Page 9 of 11
There is a program to do this automatically, which shows the changes you made and,
if an assignment is a program, runs the program and reports whether the output is correct.
You can use it yourself on this tutorial with the following command,
using your name instead of batman :
Computer Lab Techniques: GIT Tutorial
This is what I get when I run that command:
It’s showing me the log output, which includes the tag ‘finished’ on the version I want graded, and
it’s asking me if I want to see the file changes (called ‘diffs’).
Acceptable answers are ‘y’ and ‘n’, and the default answer is ‘y’, so I can just hit enter.
Then I get output that doesn’t fit in the window. Lines marked with ‘+’ are lines that were added,
and lines marked with ‘-’ are lines that were removed.
For programs, the grader will then run your program and check to see if the output is correct. Since
this is not a program, there’s nothing to do but show the changes.
8.2
What To Turn In
When you’re finished with everything, make a screenshot showing the output of the grading program
with the ‘-b’ flag and upload it on Canvas:
/opt/cs/bin/grade_program -b kilroy GitInfo batman
Page 10 of 11
The arguments here are:
-b
kilroy
GitInfo
batman
show brief output;
Rowan username of professor teaching the class;
name of the assignment; and
Rowan username of student.
This will give a briefer version of the full output.
Computer Lab Techniques: GIT Tutorial
This is what I get when I run that command (note that I’m both professor and student here, so my
username appears twice):
Instructions for making screenshots are on the web at:
http://elvis.rowan.edu/~kilroy/class/general/?ScreenShots
Id: GitTutorial.tex,v 1.16 2024/09/05 22:10:39 kilroy Exp kilroy
Page 11 of 11
D.F. Provine

Are you stuck with your online class?
Get help from our team of writers!

Order your essay today and save 20% with the discount code RAPID