A Concise Guide To Git&Github
Table of contents
Introduction
Git is probably the most powerful tool in a programmer's life. It is a version control system that keeps the record of the changes and updations a coder makes in the codebase and much more. So, it is very necessary for one who is into coding to have a basic understanding of Git and Github. So, let's get started...
Setup
First of all, a user needs to configure the information into git that can be used across all the repositories that are going to be created. It can be done using
git config --global user.name "[firstname lastname]"
for the username
git config --global user.name "raushan kumar"
and,
git config --global user.email "[email id]"
for the user's email id linked to the github account.
git config --global user.email "raushan@example.com"
This was the configuration of git in our system.
Git in Projects
git init
To use git in the projects, user needs to open the git terminal in the project folder and initialize git with following command
git init
git init
git clone
To clone an existing project on github to the local machine, we use
git clone [HTTP link or SSH link]
git clone https://github.com/code-raushan/example.git
git status
To know the details of the staged, unstaged and untracked files in an git initialised folder, we use
git status
git status
git add
To add files into staging area, we use git add .
, if each and every file has to be added otherwise git add filename
git add .
git add index.html
git commit
To commit all the changes made in the code file, we use git commit -m "message for commit"
git commit -m "message for the commit"
git branch
This command creates a branch for the codebase for better alignment of versioning.
git branch -M branchname
git remote add origin
Now as the changes in the codebase are committed, we next would like to see those changes in the github repository of the project, in order to do, we first need to make a connection between git and github using
git remote add origin URL
here the URL is the github .git link of the repository.
git push
Now the connection being set, let us push the code into the github repository using
git push -u origin branchname
git log
To see the history of the changes or commits made in the code ,we use
git log
This much knowledge is enough to get started with git and remember that git is like an ocean, never ending.. On the go, you will explore many more useful features of git that will excite you even more.
#iwritecode #ineuron #lco
`