Share your project on GitHub

Source: Internet
Author: User
Tags git client version control system

GitHub is mainly used as a repository of Git-based distributed version management systems. It can store and manage its own code and is mainly used for cooperative development of code.

After registering GitHub, you will have a free space of 0.3g, but you can only create public projects, which also meets the purpose of code sharing. My favorite is its code display method, you can directly browse your Code. The Code has been highlighted and processed by adding line numbers. It is very beautiful and has a superb experience. As a person who wants to know your code, you can choose to browse the files you are interested in online, download the compressed files directly, or clone the files to the local directory using git.

Because GitHub is based on the GIT version control system, you need to use the GIT tool to upload and modify the code. I am here mainly to share and present code, so I don't want to elaborate too much on version control. I will briefly explain how to create a new project on GitHub, and upload your own code. The premise below is that you have registered GitHub and downloaded and installed Git-Git download

Upload and share code

1. Create a project on GitHub

After logging on to GitHub, you can find a button "new repository" in the middle of the right side. After clicking it, enter the project name, description, and URL to create it, A prompt page appears.[email protected]:XXX/XXX.gitThe address of your project.

2. Configure git and upload code

After successful installation of git, if it is in Windows, it may be a little troublesome to select git bash (the command line tool that comes with gitbash when installing the GIT client) to complete everything in the command line, but remember the command lines several times. First, set git:

1 git config --global user.name "Your Real Name"2 git config --global user.email [email protected]

Then start the most troublesome step. You need to upload a file to GitHub's Git system, and you need an SSH key for authentication. Next we will start to generate the key and submit the key. Open git bash and create an SSH key:

1 ssh-keygen -C ‘[email protected]‘ -t rsa

Enter the location where the SSH key is stored. You can directly press enter to use the default path. Enter the password you want, And the SSH key is generated. Now you need to submit the key to GitHub. First open the key storage location, which contains three files, find id_rsa.pub, open it in a text editor, and copy all the characters in it. Go to GitHub and find account settings in the toolbar in the upper-right corner. On this page, there is an SSH public keys tag and select add another public key. You can enter either title or key to paste the character and submit it.

After completing these tasks, you can upload your own code. Find the code folder you want to share and upload, right-click and select git bash, or enter the folder in git bash. Create a repository:

1 git init

Select the file to be added to the repository:

1 git add .

Generally, if you want to share all the code in this folder, add ". ", the above example is like this. If you specify the parameter, you only need to set". "change to the file name. Now, you only select the file to be added to the repository. The following shows how to add the file to the repository:

1 git commit -m ‘Test‘

-M is followed by a parameter, indicating that after the code is submitted to GitHub, the description, such as the marked place, will be displayed on the code file information.

After so long, I began to upload the local repository to GitHub. The following two commands solve the problem:

1 git remote add origin [email protected]:XXX/XXX.git2 git push -u origin master

This[email protected]:XXX/XXX.gitThat is, the address generated when the project is created above. Now, open your project URL and you will find that your code has been displayed. If you want to update the code, repeat the above.

 

Share your project on GitHub

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.