Git five-minute tutorial

Source: Internet
Author: User

Many people think git is too confusing or complex version control system, this article is aimed at some people want to quickly get started using Git,

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


Entry

You need to build a repository (repository) before using Git. You can use a directory that already exists as a git repository or create an empty directory

Using your current directory as a git repository, we just have to initialize it

Git init

use our designated directory as a git repository

Git init newrepo
from now on, we will assume that you are in the Git repository root directory, unless otherwise noted


Add a new file

We have a warehouse, but nothing, you can add a file using the Add command

git add filename
You can use the add ... Continue adding task files


Submit version

Now that we've added these files, we want them to actually be saved in the Git repository,

To do this, we submit them to the warehouse

Git commit-m "Adding files"
If you do not use-M will appear editor to let you write your own comment information

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

Git commit-a-M "Changed some files"
the-a option of the git commit command can only submit all modified or deleted documents that have been managed by Git to the repository.

It is important to note that-a does not cause new files to be submitted and can only be modified.


Release version

We'll start by cloning a library from the server and uploading

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

now we can push to the server after we modify it .

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

Retrieving updates

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

Git pull

update to the specified URL from a non-default location

Git pull Http://git.example.com/project.git

It's been over five minutes?


Delete

How do you want to delete files from the repository, we use RM

git rm file

Branching and merging

Branches are done locally, fast. To create a new branch, we use the Branch command.

GIT branch test

The Branch command does not 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

and in your branch can be submitted, will not reflect changes in the main branch. When you do, or want to commit the changes to the main branch, switch back to the master branch and use the merge.

git checkout mastergit merge test

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

Git branch-d test


Itmyhome

Original: Wheat Field Technology Blog



Git five-minute tutorial

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.