GitHub is a web-based version-control and collaboration platform for software developers. GitHub allows developers to change, adapt and improve software from its public repositories for free, but it charges for private repositories. It also provides access control and several collaboration features, such as wikis and basic task management tools for every project.
- GitHub is Git repository hosting service. That provides a web-based graphical interface.
- Easy to the management of code
- Open-source software for version control
- Effective collaboration
- Bug tracker
GitHub is highly used software that is typically used for version control. It’s helpful when more than one person working on a project.
GitHub has several competitors like
- GitLab
- GitHub
- Bitbucket
- Visual studio
Why we need GitHub
It is extremely important for software developers to a web-based platform to share the projects and collaborate with other developers. This platform must be a version control system that is it must enable multiple people to simultaneously work on a single project.
- Developers need a web-based hosting platform
- Useful for version control system
- Enables for effective collaboration
- Download projects and file in one step
- Easy evaluation of each other’s projects
What makes GitHub so popular among developers
GitHub is an open-source platform and the community is really what feels it. Moreover, here you can discover the code written by others and learn from it and even use it for your projects. It is the largest shared repository easy version control system and secure cloud storage.
Getting started with GitHub
Install git and create a GitHub account
Download Git
Create GitHub account
After login into GitHub, you will see this
Start the project by clicking start project. On the left side, you can see the list of repositories and we can create a new repository.
What is a repository in GitHub…?
A repository contains all the project files and each file’s history. We can discuss and manage our project’s work within the repository. We can own a repository individually or we can share the repository with other people.
Create a Repository
Step:1 Give a name for the repository.
Step:2 Description is optional.
Step:3 You can make repository either
public or private. Choose one of those.
Step:4 Click on add a README file
Always choose a README text file for your project which
often contains the information of the project and other
necessary details.
Step:5 Click on creates repository.
After Clicking on create a repository.
Here you can see the new repository has been created by the name of DevopsUniversity
Basic GitHub Commands
Command | Usage |
$ git init [project-name] | Creates a new local repository with the specified argument |
$ git status | Lists all new or modified files to be committed |
$ git config --global user.name “[user-name]” | Defines the name you want associated with your commit transactions |
$ git config --global user. Email "[user-email-address]" | Defines the email address you want associated with your commit transactions |
$ git config --global color.ui auto | Turns on colorization of command line output |
$ git add [file] | Prepares the file for commit by logically moving it to the staged area |
$ git ls-files --stage | Lists all the files in the staged area |
$ git commit -m "[commit message]" | Adds the staged files permanently in version history |
$ git diff | Shows unstaged file differences |
$ git diff --staged | Shows file differences between staging and the last file version |
$ git branch | List branches (the asterisk denotes the current branch) |
$ git checkout [branch-name] | Switches to the specified branch and updates the working directory |
$ git merge [branch-name] | Combines the specified branch’s history into the current branch |
$ git branch -d [branch-name] | Deletes the specified branch |
$ git rm [file] | Deletes the file from the working directory and the staging area |
$ git log | Lists version history for the current branch |
$ git log --oneline | Lists version history in one line for the current branch |
$ git log –oneline –decorate --graph | Lists version history in one line, decorated in graphical form for the current branch |
$ git push [alias] [branch] | Uploads all local branch commits to remote repository |
$ git pull | Downloads from remote repository and incorporates changes |
$ git clone [repository-url] | Clones an existing repository |
$ git rebase [branch] | Rebases your current HEAD onto [branch] |
$ git stash | Temporarily stores all modified tracked files |