Introduction
Git is a version control system, and what that means is that it helps to track the changes made to your files. Git is like a smart file tracker.
GitHub is a corporation that provides hosting for software development and version control using Git. This is an amazing system because several people anywhere on the globe can come together to work on a project. Another amazing feature of Github is Github pages. This can be used to host a webpage for free. You can have a GitHub page for as many static projects as you want. To digress a little, you can keep code files, text files, image files, you name it, inside a repository.
Terminologies
Repository
A GitHub repository is a storage space where your projects can live. Sometimes GitHub users shorten this to “repo.”
Git Branching
A git branch is a new independent path of development. It is a new copy of a project. This helps to experiment with the copy without affecting the original. Branching is such an important feature in Git as it allows us to work collaboratively on files. It also allows for multiple running versions of a source code.
By default, git uses the main branch for development. Any new commits are added to this branch.
At a particular time, there might be several developers working on different problems. These problems can be worked on in different branches to ensure the separation of code until review and merging.
Git Clone
A git clone is an operation that is used to make a copy of a repository. This is used to create a local copy of a repository from GitHub.
Master
Master is the default branch name when a repository is created. This is the active branch. Please note that as of the 1st of October,2020, this branch will be called the main branch.
Merge
A git merge is the joining of a forked history back together.
Origin
This is the default name for a remote repository.
Pull request
This is a feature that makes it easy to work collaboratively. A pull request is a process that helps to notify team members that a feature has been completed. This tells the team members that they need to review the code and merge it.
Push
Git push is used to upload local commits to a remote repository.
Git Ignore
The .gitignore file is a file that tells git which files or folders to ignore.
Git Fork
A git fork is a copy of a repository. This allows users to test and debug the forked copy without affecting the original repository.
Version Control
This is a system that records the changes made to a file over time, this helps to recall specific versions.
Commit
A git commit is a collection of changes. It is mostly accompanied by a message.
Creating a GitHub repository
• In the upper-right corner of the webpage, click on ➕, and then click on New Repository.
• Give your repository a name.
• Add a description. This is optional.
• You can decide to make your repository either public or private. Public repositories are visible to the public, while private repositories are only accessible to you, and the people you share them with.
• You can create a README, which is a document describing your project. This tells people what your project does, what they can do with your project and how they can use it.
• You can create a .gitignore file, which is a set of ignore rules, that determines which files and directories to ignore before making a commit.
Getting started with commands
Some commands to start working with git on the command line are:
$ git branch
To find out the currently active branch.
$ git checkout -b new_branch
To create and switch to a new branch.
$ git add
To add the branch to the staging.
$ git commit -m "message"
To commit the branch and add a message.
$ git push origin branch
It uploads the branch.
$ git branch -m new_renamed_branch
To rename the current branch.
$ git branch -r
Lists out the different branches.
$ git merge other_branch
To merge a branch to the current branch.
$ git push origin master
Commits a change to master.
$ git checkout branch
To switch to a branch.
$ git branch -d branch
To delete a branch.
$ git push origin --d branch
To completely delete a branch from origin.
To install Git, here is the official documentation Git Installation