Git create Repository

Source: Internet
Author: User

I have applied for a git account for a long time, but it has never been used. Today I tried several commands.

I found that it is very important to understand the principle. I used SVN before and did not know the principle of git. Therefore, I am very confused about the command description.

If someone is the same as me, it is strongly recommended that you refer to [1], which briefly explains the meaning of git repository.

It is mainly to distinguish the meaning of the Work tree and the warehouse, and the warehouse is equivalent, no one warehouse is more important.

Mkdir test // create a local directory, also called the work tree CD testgit init // create a repository, which will be generated. git folder touch abc.txt // create a file git add abc.txt // Add the file to the version control index git commit-M "add file" // submit the code to the repository, A local branch named master is automatically created.

At this time, I just created a local repository, that is, the content in/test/. Git/. How can I publish it to GitHub?

First, we need to have a GitHub account, log in, and create a repository. This step is equivalent to creating an empty repository on the GitHub server. This is a remote repository. Of course, remote warehouses can also be built on another server, or even another location of your own machine.

Get address, for example: https://github.com/gogdizzy/TEST.git

Next, we will get an alias for the remote repository address (otherwise, it will be too tiring to input the remote address each time), and then publish the content of the local repository to the remote repository.

Git remote add Haha https://github.com/gogdizzy/TEST.git // name the remote address Haha, just a test, generally called origin, remember that the local branch is mastergit push Haha master. // you need to enter the user name and password to push the content of the local branch master to remote haha.

This example contains the abc.txt file in the remote warehouse.

References:

[1] Git User Guide, Li Yanrui, v 0.1, 20080728, http://pan.baidu.com/share/link? Consumer id = 3886230687 & uk = 1762127198

[2] Pro Git, Scott Chacon, July 29,200 9, http://pan.baidu.com/share/link? Consumer id = 3897454407 & uk = 1762127198

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.