How to use the command line to create a new project in github (transfer)

How to create a new project in github using the command line

http://www.jianshu.com/p/df7ce9f3a5cb (transfer)

 

Foreword: The basic knowledge of new githubaccounts and those who have already added their own computers to the default readers , let's pay attention to how to create a new project. This article refers to this articlegitSSH Keygithubgithub

Getting started with the basics of git

New projects are divided into 2 situations:
1. The code starts from scratch.
2. The project code already exists locally, but I just want to put githubit on open source or store it.

However, in either case, you must first githubcreate a new project repository. After logging githubin, find Repositoriesthe tab in the figure below, and then click the red box newto create a new project repository.

interface
interface

The interface for creating a new project repository is as follows:

New project repository interface
New project repository interface

Then enter the name of your project, the description of the project from top to bottom, and choose whether the project is public (Public) or as a private project (Private).

Initialize this repository with a README

This option is asking if you want to help you initialize a project based on the project name and description you entered (generate a README md file)

The next step is to ask if you want to add the project's ignore file (.gitigore) and whether you want to add a license to your project.

The above can be filled in and selected according to your own actual needs, and then click the green button to create a project warehouse.

It will then jump to a home page of your project.

code from scratch

You can create a blank folder locally, then clone the project you just created (ps: clone url can be found at the bottom right of the project home page) locally, then add the code and upload it.

mkdir emptyFolder
cd emptyFodler
git clone https://github.com/youraccount/yourproject.git

Then the rest is the matter of git addand .git push

Code already exists locally

  • Execute the command first in your project file directory to git initmake it a gitrepository.

  • To add all files in the project to the local repository, use the following command:

      git add .  //注意还有一个小圆点
      git commit -m "some message for this project."
  • Then githubpull the project on

      git pull https://github.com/youraccount/yourproject.git
  • Add a remote repository named origin for the repository.

      git remote add origin https://github.com/youraccount/yourproject.git
  • Execute the push command to complete the initialization of the GitHub repository. Pay attention to the -u parameter in the command line, after the push is successful, the tracking of the local branch and the remote repository branch is automatically established

      git push -u origin master

PS: If the links and content involved in the article are infringing, please let me know, and I will delete them. If there are any mistakes or omissions in this article, please correct me. thanks. :P

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326987691&siteId=291194637