GitHub Lecture 1
GitHub Lecture 1
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.
❖ Source code
❖ Documentation
❖ Short stories
❖ Binary files (music and pictures)
❖ 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
❖ Backup
❖ Easier Branching
Git Repositories
❖ Local repository: one on which we will make local changes, typically this local repository is
on our computer.
❖ 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.
❖ 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.
▪ 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".
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.
❖ The install
Configure Eclipse for Github
❖ Select Help > Install New Software > https://download.eclipse.org/egit/updates
❖ In the top right corner search box write the Git repository and select that.
❖ 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)
❖ 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)