1. What is the difference between git and GitHub?
-
Git is a version-tracking software which allows teams to collaborate and contribute code to a project in parallel. The git software is run locally on machines and/or networks where developers can interact with git through the terminal.
-
GitHub is a social platform which integrates with git profiles. GitHub provides tools to developers and teams through using git, and allowing contributors to make push and pull requests to any project, and also make comments in the code etc. The list goes on… GitHub has established itself sort of as the Wikipedia for open-source programs. It is home to millions of open source code bases
2. What is the staging area?
The staging area is the intermediary stage between editing code on the working directory, and committing to production.
A developer will generally work on some piece of code or feature on their machine in the working directory. When they feel it is sufficient to be placed into the review step, they will generally add it to the staging area.
If they are working as a team, this is generally where supervisors or other team members will review and test the code, comment on it, make changes etc. before committing the code live into production.
3. What does the -m switch do in git commit?
The -m switch allows the person who is making the commit to attach a message describing the commit.
This is usually a comment on what has been added in this commit, or a certain feature etc.
The message to proceed the -m switch, as follows:
git commit -m "Added new H1 style to the head of the About Page."
Without the -m
switch, you will typically be prompted for a message by a text editor, however the -m bypasses it and automatically appends it to the commit.
4. What is the difference between merging and rebasing?
Both merging and rebasing happen when two paths of development unify into a single branch. This can be done by merging, or rebasing.
Merging happens when an alternative ‘feature’ branch is being developed alongside the ‘main’ branch. There will usually be various commits of both branches along the way before the feature branch is fully functional, tested and ready to go live. When the team decides they’re ready to incorporate the feature into the main branch, they can merge the two branches, retaining the commit history of both, in case of bugs, blames and comments etc.
Rebasing accomplishes much the same thing as merging, but with a small yet impactful difference. When a rebasing takes place, the feature branch begins at the end of the main branch, and all commits made to the main branch are incorporated into the feature branch.
The benefits of merging is that it is much less destructive than rebasing where everything is kept and there can be exhaustive merge commits for the feature branch if the main branch is very active.
While rebasing is more destructive than merging a main branch into a feature branch, rebasing provides a cleaner commit history. The problem with rebasing however, is that the history does not provide context through when upstream changes were incorporated into the feature branch. These rebasing methods are usually best for solo developers and small teams.
5. What does git clone do?
A git clone is when someone ‘forks’ a code repository. When a developer performs git clone
, a copy of the subject repository is stored on their computer for them to edit.
6. What is forking?
Forking is the conceptual attribute of cloning: it is taking some existing code base, and changing it. A developer could appreciate many parts and features of a repository, but they think they could do ‘x’ better, or remove ‘y’.
So they clone the repository, make changes to it - and often publish their revised version of the repository.
Their separate version is considered a fork of the original repository.
7. How can we host a website on GitHub Pages?
GitHub allows its users to assign the repository name to your username as a subdomain for github.io, e.g. username.github.io
, GitHub will do the rest and have the repository hosted as a website.
Once you do this, GitHub will set up a new gh-pages repository branch for the website.