Upload a new local project to GitHub's new warehouse

Source: Internet
Author: User

Preface: Someone asked me how I uploaded my files to my new GitHub warehouse, and I saw some people in the group asking. So I'm going to write an article, record how to upload the local new project to their GitHub warehouse, hoping to help people who still do not understand, the big God, Daniel, Danale please ignore. 1. Create a new local library

Find a path to create a new folder, or you can use Git-bash

Open git bash and use mkdir to create a folder

Command:

mkdir python2                  #新建名为python2的文件夹cd python2                       #进入文件夹git init                              
2. Add the project file you want to upload to the new local library
    • Copy the project files or folders that you need to upload to GitHub to the new Python2 local repository

    • And then through git Add. Add all the files in this directory to the warehouse, note that the points are separated by a space

      Command:
      git status       #查看状态git add .         #把该目录下的所有文件添加到仓库
    • Commit the project file to the repository using the git commit command

      Command:
      git commit -m "first commit"       #添加-m参数,提交的注释内容
      3. Create SSH Key
    • Or in GIT bash Terminal input command
      git config --global user.name "你的GitHub用户名"git config --global user.email "你的GitHub注册邮箱"ssh-keygen -t rsa -C "你的GitHub注册邮箱"
    • When prompted to set the password, press the ENTER key directly. Because that is to set your secret key password, set up, each time you use the secret key to enter the password. I use their own computer usually only their own use, so do not set the secret key password, if you are using a public computer, you can set the secret key password to ensure that the secret key security.
    • Add a public key to GitHub


4. Create a warehouse on GitHub
    • You can directly point to new repository to create
      Create a warehouse on 5.Github and associate it with a local warehouse
    • associating commands
      git remote add origin https://github.com/blurcat/python2-project.git#注意origin后面加的是你Github上创建好的仓库的地址
6. Push all the contents of the local library to the remote repository (GitHub new library)

    • In addition, there is a point to note that when you create a github repository above, if you tick the initialize this repository with a readme (that is, create a repository automatically when you create a readme file), That's when the local repository content is pushed to the GitHub repository and a error:failed to push some refs to ' https://github.com/blurcat/python2-project.git ' is reported
    • This is due to the newly created repository inside the Readme file is not in the local repository directory, you can use the following command to first merge the content:
      git pull --rebase origin master
    • After merging, push will be successful.

Upload a new local project to GitHub's new warehouse

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.