This tutorial will give you an idea to use GIT as your source code repository. You can use tortoise GIT or command line to use git. This tutorial is targeted to command line users.
INSTALL GIT
This is very easy, just download and install git. You can just skip all the steps by clicking next button allowing default configurations.
after successful installation you can right click and select ‘Git bash here’ to enter git command line quickly.
GIT CLONE
This command used to download the source to your directory. Go to your desired folder and type below command in git bash.
git clone <git repository url>
GIT STATUS
This command will show you all the updates and files need to commit in your repository
git status
GIT ADD
This command used to add a newly created file to the repository
git add <file path with name>
GIT COMMIT
This command will commit your code to your local git repository. You also need to provide a comment for the commit.
git commit -m “message for the commit”
GIT PULL
This command will update your local repository from your hosted repository. go to your project directory and run below command in git bash.
git pull
GIT PUSH
This command will update hosted repository from your local repository. Go to your project directory and run below command in git bash.
git push
GIT BRANCH
This command will show all the branches available in your hosted repository.
git branch -a
GIT FETCH
This command will fetch all the branches available in the hosted repository to your local repository.
git fetch
GIT CHECKOUT
You can switch between branches using this command.
git checkout <branch name>
HOW TO MERGE BETWEEN BRANCHES
To merge branches you have to follow below steps. Ill tell this using an example. Assume you have two branches as ‘master’ and ‘dev’. You need to merge source from dev to master. Follow below steps, apply same steps according to your scenarios.
go the root directory and type below command in git bash.
git checkout dev
git pull
git checkout master
git pull
git merge –no-off –no-comment dev
Following this steps will merge source in your local git repository. If you push right away it will merge even in the hosted git repository.