Seminar Report On Git and Github
Seminar Report On Git and Github
Submitted to:-
Asst. Prof. & HoD
Murlidhar Prasad Singh
Submitted By:
Name: Anupam Tiwari
Roll No.: 19424
Reg. No.: 19105128010
Branch: Computer Science & Engineering
Batch: 2019-23
2
Preface
I have made this report file on the topic “Git and GitHub”; I have tried
my best to elucidate all the relevant detail to the topic to be included in
the report. While in the beginning I have tried to give a general view
about this topic.
First, I would like to thank everyone who were present during the
seminar. It is indeed with a great sense of pleasure and immense sense
of gratitude that I acknowledge the presence of these individuals.
___________________
3
Contents
Git is designed to deal with exactly this sort of situation. Unfortunately it doesn’t work that
well with ‘binary’ files like the .doc or .docx files that Word uses, but for plain text files of
the sort you use for writing programs and scripts, or files that you use with LaTeX (the
typesetting system used to write these tutorials), it removes these sorts of problems
completely. What’s more, you can synchronize git with GitHub on the web giving you a
backup of what you have done, allowing you to collaborate with others and to publish what
you have done to share it with the outside world. Some journals (such as F1000) are even
requiring that people who write papers describing code deposit it in GitHub. If you write code
to do your research, you can ensure that you tag your code in GitHub with a version number
so that when you publish your research you can tie it to a specific version of the code
allowing you (and others) to recover exactly the version of code that was used to create your
results. Git and GitHub are separate things, but linked. Git is the software that runs on your
computer and manages your files. You don’t need to use it with GitHub. GitHub is an online
platform that allows you to synchronise your local Git repository onto the web. You can also
use GitHub to browse other people’s repositories and download code or documents without
ever using Git.
Installing Git
• In GitHub, click the menu item at the top right (it may be a picture of you if you have
added a profile picture) and choose Settings from the menu.
• Select SSH and GPG keys from the menu on the left.
• Click New SSH key towards the top right.
• Enter a title for your SSH key in the box — this can be anything you like, but
probably something that identifies the computer you are using (e.g. Andrew’s
Windows laptop).
• Cut and paste the whole of the public key that you displayed a moment ago (the
content of id_rsa.pub) into the Key box.
• If you are using a Mac, use:
pbcopy < ~/.ssh/id_rsa.pub
or get the public key into your clipboard so you can paste it into GitHub.
• Click Add SSH key at the bottom of this section of the web page.
Configuring Git
You need to type two lines to configure Git and link it to GitHub.
In the following commands:
Command Effect
Now you need to create a directory for your project repository and enter that directory. For
this tutorial we will call it GitExercise:
Type the following:
Note that it is a good idea to avoid spaces in directory (and file) names since you will have to
put the name in inverted commas or escape each of the spaces with a backslash which can be
a real nuisance!
We now need to tell Git that this is a Git repository:
Type the following:
colour while you are working on it (for example to highlight syntax while writing a computer
program) but this information is not saved. Under Windows, you can use NotePad (ensure
you save as a ‘plain ASCII text file’), but other freely-available editors include Atom and
vim (also known as vi). On the Mac, choices include TextEdit or vim. vim is built into the
git-bash environment, but is rather old-fashioned and not easy to use — its advantage is it is
available in every unix-like environment and lots of programmers really like it because it is
very fast to start and pretty powerful. It is also the default editor that Git will use if it expects
you to provide information about a change you have made. vim has a ‘command mode’ and a
‘text-entry mode’. When vim starts, it will be in command mode. To add text, move around
using the arrow keys. To start entering text at the cursor, press the i key (for insert) and start
typing.
When you are done press the Esc key to return to command mode. To exit the editor, press
Esc to ensure you are in command mode, then type: wq.
Exit your editor and tell Git that you want to track this file:
Type the following:
You only need to do this when you have a new file that you want to track with Git. Having
specified that the file should be tracked, we need to tell Git that we have made changes to the
file that we want it to record:
Type the following:
Strictly in this case the -a isn’t needed, but it will be whenever you do this in future so we
will put it in. The -m specifies the text that follows in double-inverted commas is a comment
(or message) briefly explaining what changes were made in this version. If you forget to
supply a message with -m then you will enter the (vim) where you can enter text (See the
notes above).
9
Having just committed your changes, you should receive the message:
On branch master
nothing to commit,
working directory clean
Let’s create another file that isn’t being tracked just to see what happens:
Type the following:
The touch command is used to set the date and time on a file to the current date and time. If
the file doesn’t exist, it creates it, so we are just using this to create an empty file. This time
the output from git status should look something like:
On branch master
Untracked files:
(use "git add ..." to include in what will be committed)
foo.txt
nothing added to commit but untracked files present (use "git add" to track)
Git warns you that there are files present that aren’t being tracked. Since we only created this
file as a test, let’s delete it again:
Type the following:
This will list all the commits you have made with the comments that you specified with -m.
The commit line in the output will be followed by a random string of characters — something
like b5526a8ddb40925e01620e751ecc97b735464444.
10
Now if we check the status we will be told that one of the files has been modified:
Looking at the output from git log you should now see that there is a log message for your
changes.
• Go to the GitHub.com web site and make sure you are logged in,
• In the top right corner, you should find a + sign. Click this and then click New
repository, \
• Enter the name of your repository (GitExercise),
• Add a description of your repository — something like “Git Exercise”,
• Do not select the option to “Initialize this repository with a README”,
• Click the button to create the repository
11
These steps have created an empty repository on GitHub; you now need to synchronize your
local repository with this.
Replace USERNAME with your GitHub username in the following.
Type the following:
If you make a mistake in this command (such as not using the current username or repository
name), you can delete the remote repository and start again with git remote remove origin.
From now on, after you make and commit changes, all you need to do is git push (without
the -u origin master) to ‘push’ your changes onto GitHub.
Git Commands
• git config • git rm
• git init • git log
• git clone • git show
• git add • git tag
• git commit • git branch
• git diff • git checkout
• git reset • git merge
• git status • git push
• git remote • git pull