Git simple guide

I would like to share some basic information about the best and geeky version controlling system I’ve ever used.

What is Git?

GIT is an open-source version controlling system which you can use to maintain code for your project. It helps you to save your project at different versions so that you can retrieve a previous version of your project without any problem

Git allows a team of people to work together, all using the same files. And it helps the team cope with the confusion that tends to happen when multiple people are editing the same files.

The git basics tutorial provides a succinct overview of the most important Git commands.


 Git basic command line commands


 

git init

The git init command initializes a new Git repository.

Usage

git init

Create an empty Git repository in the specified directory. Running this command will create a new folder called containing nothing but the .git subdirectory.

git init –bare

Initialize an empty Git repository, but omit the working directory. Shared repositories should always be created with the –bare flag.

Central repositories should always be created as bare repositories because pushing branches to a non-bare repository has the potential to overwrite changes.


git clone

The git clone command creates a copy of an existing Git repository.

git clone

Clone the repository located at onto the local machine. The original repository can be located on the local filesystem or on a remote machine accessible via HTTP or SSH.

Usage

git clone

Clone the repository located at into the folder called on the local machine.


git config

The git config command is a convenient way to set configuration options for your Git installation.

Usage

git config user.name

Define the author name to be used for all commits in the current repository. Typically, you’ll want to use the –global flag to set configuration options for the current user.

#To configure the name of the author.

git config –global user.name

#To configure the email address of the author.

git config –global user.email


 Recording Snapshots


 

git add

The git adds command moves changes from the working directory to the staging area. This gives you the opportunity to prepare a snapshot before committing it to the official history.

Usage

//To stage all changes in for the next commit.

git add . 

Here ‘.’ represents all files in the current directory.


git commit

The git commit takes the staged snapshot and commits it to the project history. Combined with git add, this defines the basic workflow for all Git users.

Usage

git commit

Commit the staged snapshot. This will launch a text editor prompting you for a commit message. After you’ve entered a message, save the file and close the editor to create the actual commit.

git commit -m “commit message”

Commit the staged snapshot, but instead of launching a text editor, use as the commit message.

git commit -a

Commit a snapshot of all changes in the working directory. This only includes modifications to tracked files.


 Inspecting a Git Repository


git status

The git status command displays the state of the working directory and the staged snapshot. You’ll want to run this in conjunction with git add and git commit to see exactly what’s being included in the next snapshot.

Usage

git status

List which files are staged, unstaged, and untracked.


git log

The git log command lets you explore the previous revisions of a project. It provides several formatting options for displaying committed snapshots.

Usage

git log

Display the entire commit history using the default formatting. If the output takes up more than one screen, you can use Space to scroll and q to exit.

git log -n

Limit the number of commits by . For example, git log -n 3 will display only 3 commits.

git log —oneline

Condense each commit to a single line. This is useful for getting a high-level overview of the project history.

git log —stat

Along with with the ordinary git log information, include which files were altered and the relative number of lines that were added or deleted from each of them.

git log -p

Display the patch representing each commit. This shows the full diff of each commit, which is the most detailed view you can have of your project history.


#Thank you all for reading my blog please have a try with what you have learned.

http://try.github.io/

One thought on “Git simple guide

Leave a comment