An Ultimate Guide to Git and GitHub
If you are a developer then you must be aware of GIT and GITHUB, as it is a place where developers live, where many developers around the world contribute to an open-source projects every day and night and many more.
Read this full article there is one bonus tip for you at the end ;)
What is GIT?
GIT is a Version Control System (VCS).
So what is Version Control System?
If you are a developer then you must be working on many projects so at this time Version Control System comes into play, it is used for file management, keeping tracks of changes overtime of your projects which is one of the most primary things, also it keeps the entire history of things that you are working on.
This is helpful for those developers who first made their basic version then adding new features in future without affecting the original version.
Another amazing feature offered by GIT is, it allows many developers around the globe to work together on the same project at the same time without disturbing each other’s files, by working on different branches. Collaboration is easy in GIT and team members can work on different features in same project.
GITHUB
What is Github?
GitHub is a world’s leading software development platform, it is a web-based service for version control using Git. It builds collaboration directly into the development process. Work is organized into repositories, where developers can outline requirements or direction and set expectations for team members.
1) Basic terms you must know..
a) Repository:- A Repository, or a repo, or a git project, encompasses the entire collection of files and folders associated with a project, along with each file’s revision history.
b) Fork:- Fork is basically a copy of other user’s repository that lives on your personal Github account, main reason behind this this is to customize others repository according to your need.
c) Master:- “Master” is a default development branch, when you create a brand new repository. After creating a repository you can make further more branches to work on.
d) README.md:- README.md file is the descriptive and the basic file of the projects which contains the extract/description of the project.
With this we are all set to dive into the world of Git and Github, and to collaborate with the world’s leading developers :)
2) Installation process
a) For Linux users:
Use your Linux package management system to install Git.
> sudo apt-get install git
b) For Windows Users:
It’s recommended to download GitHub for Windows, which includes Git and has an easier install: windows.github.com. Use the Git Shell for your terminal.
c) For Mac users:
Mac.github.com (from Preferences, select the command line tools install), or download Git by itself at: git-scm.com/downloads and follow the installation instructions.
Or, install Homebrew and run the following to install an up to date version of Git on your Mac:
> brew install git
To update your Git install, use Homebrew’s upgrade option:
> brew upgrade git
3) Configure Git
Once Git is installed, open terminal/shell/command prompt/bash
Run the following commands:
#This command will return the latest version of your git version
>$ git --version#Set your name
>$ git config --global user.name "<Your Name>"#Set your email
$ git config --global user.email "<youremail@example.com>"#verify with
>$ git-it verify
4) Basic GIT commands.
a) $ git init
:- initializes a brand new Git repository and begins tracking it.
b) $git clone
:- copy of a repository which is hosted on Github, into a folder on your local machine.
c)$git add
:- tracks your file and changes in GIT.
d)$git commit
:- saves your files in GIT.
e)$git status
:- shows the status of changes as untracked, modified, or staged.
f) $git branch <new branch-name>
:- creates new branch for your project.
g)$git checkout <branch-name>
:- “checkout” switches between the branches in a project.
h) $git merge
:- merges lines of development together.
i) $git pull
:-updates the local line of development with updates from its remote counterpart. Developers use this command if a teammate has made commits to a branch on a remote
j)$git push
:- upload git commits to a remote repository like Github.
There are many more commands to learn but these are some basic and most used GIT commands that will make your developer’s life hustle free. Learn these commands to take a head start :)
Developers now its your turn to contribute for the future generation!!
5) Demonstration for reference
#Create new folder example: demo>cd demo #change directory#create README.md file>git init #initialize a new repository>git status #you can see untracked README.md file>git add README.md #adds README.md file>git status #now you can see README.md file is tracked>git commit -m "initial commit">git remote add origin master <link of repository>>git remote -v #to check the working of repo>git push -u origin master
6) BONUS TIP!!!
I’m sure that you must be waiting for this “BONUS TIP”, so without wasting any time let’s get started ;)
The bonus tip is that Github offers you to personalize your own profile in a more visually appealing way…..
So, how to make this awesome repository?
It is simple just make a new repository with the name same as your username, then it will show you this green box with a message “You found a secret! <your name>/<your repository name> is a special repository that you can use to add a README.md to your Github profile. Make sure it is public and initialize it with a README to get started”
Just simply check my Github account and fork my repository, edit it and personalize it according to your need.
Closing Notes
Now with this we come to an end of our discussion and if you have read this article so far kudos to you, now you can contribute, collaborate with world’s leading developers.
I hope you liked this article.
And if you want to start your Web Development journey you can check this out.
An investment in knowledge pays the best interest.
Again thanks a lot and all the best for your future!
You can contact me anytime in case of doubts and assistance.
Email:- adaksh5@gmail.com
Web:- http://www.akshatsrivastava.tk/
LinkedIn:- https://www.linkedin.com/in/akshat-srivastava-4812271a9/
Github:- https://github.com/akshat-fsociety