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

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


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 Git repository

 git init newrepo

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

Add New File

We have a warehouse but 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 we have added these files, we hope they can really be saved in the Git repository,

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 many files, instead of adding every one, we can use the - a flag to automatically commit local changes

 git commit -a -m "Changed some files"

The - a option of the git commit command can only</span> Documents that have been modified or deleted and have been managed by git Submit to the warehouse.

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

Release version

First, we 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

Update from non default location to the specified url

 git pull

More than five minutes?


How do you want to delete files from the repository? We use rm

 git rm file

Branch and Merge

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

 git branch test

The branch command will not take us to branches, 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 submitted, it will not reflect changes in the main branch. When you do or want to submit changes to the main branch, switch back to the master branch and use merge.

 git checkout master git merge test

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

 git branch -d test