0% found this document useful (0 votes)
62 views

GitHub Lecture 1

The document provides information about setting up GitHub in Eclipse. It discusses downloading and installing Eclipse and Git, configuring Eclipse to work with GitHub by installing the EGit plugin, adding the GitHub repository perspective, cloning a repository from GitHub into Eclipse, and adding an Eclipse project to a GitHub repository. The steps covered include creating a GitHub account and repository, generating a personal access token, downloading Eclipse, installing the EGit plugin, cloning a GitHub repository into Eclipse, creating a sample dynamic web project, and converting it to a Maven project to prepare it for deployment to GitHub.

Uploaded by

Rakib Mia
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views

GitHub Lecture 1

The document provides information about setting up GitHub in Eclipse. It discusses downloading and installing Eclipse and Git, configuring Eclipse to work with GitHub by installing the EGit plugin, adding the GitHub repository perspective, cloning a repository from GitHub into Eclipse, and adding an Eclipse project to a GitHub repository. The steps covered include creating a GitHub account and repository, generating a personal access token, downloading Eclipse, installing the EGit plugin, cloning a GitHub repository into Eclipse, creating a sample dynamic web project, and converting it to a Maven project to prepare it for deployment to GitHub.

Uploaded by

Rakib Mia
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

Internet and Web Technology Lab

ICT- 2206
Topic : GitHub
Lecture - 1
Presented By:
Mehrin Anannya
Lecturer
Institute of Information Technology
Jahangirnagar University.
Contents
❖ Version Control
❖ VCS and their operations
❖ Centralized VCS
❖ Distributed VCS
❖ Git
❖ GitHub
❖ Hands on Practice
Version Control
A system for managing changes made to documents and other computer files.

What kinds of files can we use it with?

❖ Source code
❖ Documentation
❖ Short stories
❖ Binary files (music and pictures)

What should we use it for?

❖ Source code
❖ Text files
❖ Projects that have lots of revisions (changes)
❖ Collaborating
VCS and their Operation
Lots of different choices available:

❖ CVS
❖ SVN
❖ Perforce
❖ Git
❖ Mercurial (Hg)
❖ Bazaar
❖ And more!

Most follow a repository model (though differ in how the repositories work)
Git
Git Introduction
❖ Git is a distributed version control system that allows developers to track changes in their computer
files and work in collaboration with other developers.

❖ It was created by Linus Torvalds, the creator of Linux, in 2005 for allowing other developers to
contribute towards the Linux kernel.

❖ Distributed version control system means that there is not a single repository centralizing all the code
history. All the code history is in each repository, which means that you have all the history in your
local repository as well as in the others.

❖ It is known for amazing functions such as speed, simple and easy to use design, support for
non-linear development, full distribution and ability to handle large projects with efficiency.

❖ Though acronym of Git shows as global information tracker but Linus named it by its meaning - ‘an
unpleasant or contemptible person’.
Advantages of Git
❖ Free and Open Source

❖ Fast & Small

❖ Backup

❖ Easier Branching
Git Repositories
❖ Local repository: one on which we will make local changes, typically this local repository is
on our computer.

❖ keywords : commit, branche, merge, rebase, etc.

❖ Remote repository: one of the server, typically a machine situated at 42 miles away. The
purpose of a remote repository (e.g. - GitHub) is to publish your code to the world (or to some
people) and allow them to read or write it.

❑ The remote repository is involved when you git push your local commits to remote repo
& git pull when someone else’s commits from it.
Git working procedure

git pull
GitHub
GitHub Introduction
❖ A web-based Git repository hosting service, that offers all the functions of distributed version
control and source code management (SCM) functionality found in Git, as well as adds more.

❖ It is commonly used in collaboration with Git and allows developers to save their coding online
and then collaborate with other developers on different projects.

❖ GitHub also provides access control, plus also collaboration functions such as bug tracking,
feature requests, task management, and wikis for every project.

❖ The objective of GitHub, and what it is marketed as, is to simply promote collaborations
between developers, allowing them to get a new set of ideas on the project.
GitHub Features
❖ Share your repositories with others.

❖ Access other user's repositories.

❖ Store remote copies of your repositories (github servers) as backup of your local
copies.
Comparison with SVN
❖ In the SVN analogy, Git replaces SVN, while GitHub replaces SourceForge.

❖ The key difference is that it is decentralized. Imagine you are a developer on the road, you develop
on your laptop and you want to have source control so that you can go back 3 hours.

❖ With Subversion, you have a Problem: The SVN Repository may be in a location you can't reach
(in your company, and you don't have internet at the moment), you cannot commit. If you want to
make a copy of your code, you have to literally copy/paste it.

❖ With Git, you do not have this problem. Your local copy is a repository, and you can commit to it
and get all benefits of source control. When you regain connectivity to the main repository, you can
commit against it.
Hands on Practice
Hands on Practice Contents
Account creation in GitHub
Download and install Git in PC
Git in Visual Studio Code
Git in Eclipse
Download eclipse and ready to use
Create a repository in GitHub
Configure Eclipse for Github
Add the Github repository perspective in eclipse
Clone the repository in eclipse
Add eclipsed project to GitHub repository
How to commit, pull and push
Account creation in GitHub
❖ Go to https://github.com/login
❖ Create an account
Download and install Git in PC
❖ Download git in your system Because it will be tied up with GitHub , it is an
underlining technology that powers GitHub

❖ https://git-scm.com/downloads
Create a repository in GitHub
❖ Sign in to https://github.com/login

❖ If there is Start A project then select that or click the Repositories and click the New
button.

❖ Give the repository name in which you will keep the project folder.

❖ Press the Create repository button.

❖ After its creation copy the created link.


Git in VSCode
Git commit and push
▪ Settings-> github enable is checked
▪ Open an existing project in vscode from file explorer or from View -> command
palette -> Initialize Repository
▪ In source control menu -> initial repository -> locate your project to commit locally
▪ Unstaged files will be in the file explorer to be selected for staging area (click +).
▪ In the search menu write the git message to commit and click the check mark to
commit locally.
▪ After the local commit, Publish Branch will appear to commit remotely.
Git in VSCode…
Git commit and push …
▪ Remote or Github can be done in two process.
1. Creating a new repository directly from VSCode
2. Creating a new repository in the GitHub and locating it for VSCode project
Git in VSCode…
Creating a new repository directly from VSCode
▪ Click Publish Branch then it will create a new repository and will upload all the files in
your account in that repository.
Git in VSCode
Creating a new repository in the GitHub and locating it for VSCode project
Push by creating a repository in the github with the project name in the VSCode

▪ After the local commit, Publish Branch will appear to commit remotely.

▪ IF an error dialog box comes for login problem, write the following in the terminal: git config
--global user.name "Your GIthub_Username" & git config --global user.email "Your
Github_email".

Example: If anyone’s username is “ABC” and email of it is [email protected] then

git config --global user.name ABC

git config --global user.email [email protected]

▪ Click Publish Branch -> Publish to GitHub public repository.


Git in VSCode
Git commit and push (cont.)

Push in the created repository in the github with the github Repository link and the
Repository Name

▪ After the local commit, Publish Branch will appear to commit remotely.

▪ Add the remote repository: View -> command palette -> type Git: Add remote ->
Select the project’s Name -> Copy the repository link from the desired github’s
created repository. ->Paste it in the Git: Add Remote search option -> Click Add
remote from Github -> Sign in to Github account (if required) -> Write the
Repository’s Name -> Publish Branch
Git in VSCode

Git pull
• Suppose, you are in a git repository sync with github.
• Add a file in the Github.
• Write some code into it.
• Then commit.
• Now in vscode from that sync repo, click the pull request.
• You will see the added file in the vscode file explorer.
Git in VSCode

Git clone
▪ View -> command palette -> type Git: Clone.
▪ Copy the github repository link which will be cloned from Code option of the
Github repository
▪ Select a folder where you will clone the repo
▪ Click Clone from Gtihub
▪ Repo is cloned locally
▪ Change the files and push
Github Setup in Eclipse
Create a repository in GitHub
❖ Sign in to https://github.com/login

❖ Create a token (Settings > Developer Settings > Personal access tokens) > Give a
name in the Note field > Select the repo checkbox > click Generate token. Copy the
token and preserve it for future use (It has to be used for authentication while doing
push pull).

❖ If there is Start A project then select that or click the Repositories and click the New

button.

❖ Give the repository name in which you will keep the project folder.

❖ Press the Create repository button.

❖ After its creation copy the created link.


Download eclipse
❖ Sign in to https://www.eclipse.org/downloads/

❖ Select the installer

❖ After its installation, select the desired eclipse IDE

❖ The install
Configure Eclipse for Github
❖ Select Help > Install New Software > https://download.eclipse.org/egit/updates

❖ and the follow the figures:


Configure Eclipse for Github (cont.)
Configure Eclipse for Github (cont.)
Add the Github repository perspective in Eclipse

❖ In the top right corner search box write the Git repository and select that.

❖ Then after its addition in the lower left corner.

❖ Select the Clone a Git repository.

❖ Then in URI paste the copied clone url(Ex -


https://github.com/Mehrin-Anannya/ICT-2206-repo.git) from github here.

❖ Give the username and password.

❖ Then hit the finish.

❖ Then its local repository is ready to work here to get upload from here to the github
repository.
Add eclipsed project to GitHub repository
❖ Create a Dynamic Web Project: File > New > Web > Dynamic Web Project >
give a name > Finish

❖ Select the project > Configure > Convert into Maven project (Maven will be
taught in the next slide)

❖ Add Dependencies in pom.xml (4 dependencies)


How to commit, push and pull in GitHub?
❖ Select the project > Right click on it > Team > Share Project > Configure Git Repository >
From Repository dropdown select your repository > Finish

❖ Commit and push: Commit the project in the repository: Select the project > Team
>Commit > From Unstaged Changes select the files and drag and drop in the staged changes
> Add comment > Commit and push / Commit > Push to branch in remote > Preview/ Next >
Give login credentials (you can check the store for future credential check)

❖ Pull: Team > Pull Request

You might also like