How to Use Git ?

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Git is easy to learn and has a tiny footprint with lightning fast performance. It outclasses SCM tools like Subversion, CVS, Perforce, and ClearCase with features like cheap local branching, convenient staging areas, and multiple workflows.

Install GIT
For window:
Install GIT software from one of the below URLs.

For Ubuntu:
sudo apt-get install git

Configure GIT account on your system
Open git command console and run two commands. Replace email and username of your git in the command.
git config –global “email address”
git config –global “password”

Clone GIT branch
This is the first command to initialize the project

Go to GitHub
Go to branch from where you want to clone
Click on ‘clone or download’ button
Copy ‘clone with https’ URL e.g.……../…….git
Create a directory on your system and go to the new directory
Run under command:
git clone……../…….git

GIT checkout
You can switch one branch to another branch
eg. git checkout dev[branch name]
git checkout design

You can add file to GIT
git add.

GIT commit
git commit -m ‘added files’

GIT Push
Push the branch on git :
git push origin [name_of_your_new_branch]
eg. git push origin dev

GIT Pull
Pull the changes from git to your system :
git pull

GIT Remove
git rm filename
Please don’t remove file or folder without git commands.

List Branches
You can see all branches created by using :
git branch

GIT Status
This is the very very useful command, so you can use this command before using any command to know exactly where are you. To heck updated code and also confirmation of which branch you stand
git status

Git command for testing with sequence
– git init
– git clone
– git checkout branch_name
– Add test file like test.txt
– git add.
– git commit -m ‘add test file’
– git push origin branch_name
– Put username and password of git when asked
– Check new added test.txt file on branch of git

Leave a Reply

Your email address will not be published. Required fields are marked *