Get started with Git by example on Ubuntu

Install Git

 git config –global

set global config for the current user.

git config file ‘.gitconfig’ will be created in the current user home directory.

git init –bare <repository>

Create a bare repository as a “central” repository.

git clone <repository> <directory>

Copy the “bare repository” to your local working folder.  This is sort of like “svn checkout”, except the “working copy” has its own history.

git add & git status & git commit

Initiate a new project

git remote

List the connections you have to the other repositories.

git push <remote> <branch>

Before pushing local contributes to the bare repository (central repository), make sure that your local master is up-to-date.

git fetch <remote> <branch>

Import your commits from your bare repository to your local repository. And save the commits as remote branches instead of the normal local branches that we’ve been working with. It has no effect on your local work.

git branch

git merge

Merge the remote branch “origin/master” into your local branch “master”. Then your local work are synchronized with the “remote bare repository”.

git pull

“git pull” complete “git fetch” and “get merge” works into one command.

Leave a Reply

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