Many people think Git is too confusing or complex version control system. This article is for some people who want to get started with git quickly,

For most basic requirements, this article covers 70% to 90% of usage


Before using git, you need to establish a repository. You can use an existing directory as a git repository or create an empty directory

Using your current directory as the GIT repository, we just need to initialize it

 git init

Use our specified directory as the GIT repository

 git init newrepo

From now on, we will assume that you are in the root directory of GIT repository, unless otherwise specified

Add new file

We have a repository, but there is nothing. You can use the add command to add files

 git add filename

You can use add... To continue adding task files

Submit version

Now that git has been added to the repository, we hope to save them,

To do this, we submit them to the warehouse

 git commit -m "Adding files"

If you don't use - m, an editor will appear to let you write your own comments

When we modify a lot of files and do not want to add each file, and want to commit to submit local changes automatically, we can use the - a identifier

 git commit -a -m "Changed some files"

The - a option of the GIT commit command can only change all</span> Modified or deleted documents that have been managed by Git Submit to the warehouse.

Please note that - a will not cause a new document to be submitted, it can only be modified.

Release version

Let's clone a library from the server and upload it

 git clone  ssh:// ~/www/project.git

Now we can push it to the server after modification

 git push  ssh:// ~/www/project.git

Retrieve updates

If you have pushed as above, the following command indicates that the current branch is automatically merged with the only tracking branch.

 git pull

Updates from a non default location to the specified URL

 git pull

More than five minutes?


If you want to delete a file from the repository, we use RM

 git rm file

Branching and merging

Branching is done locally and fast. To create a new branch, we use the branch command.

 git branch test

The branch command doesn't take us into the branch, just create one. So we use the checkout command to change the branch.

 git checkout test

The first branch, or main branch, is called "master.".

 git checkout master

While your branch can be committed, changes will not be reflected in the main branch. Or, if you want to switch back to the main branch, use the master.

 git checkout master git merge test

If you want to delete a branch, we use the - D flag

 git branch -d test