Use Git to upload local projects to github/coding/code cloud

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

Git is an open source distributed version control system that can efficiently and rapidly handle project versioning from very small to very large.

This article takes the example of using Git to upload a local project to GitHub, providing a way for those newcomers to git to upload a local project to the github/coding/code cloud using Git.

Sign up for a GitHub account and install Git
    • Start by registering your GitHub account and adding new items.
    • Download and install git, the installation path can be modified by itself, some settings during the installation select the default.

      Use Git to upload local projects to GitHub
    • In the local project folder, right-click to select "Git Bash here"
    • Git Global Settings

$ git config --global user.name "user.name"$ git config --global user.email "user.email"
  • Initializing the Git repository

    $ git init

  • Add File

    $ git add .

    Note the following "." Don't forget to write. If you want to sync only one file, you can change the "." To the "file name" that you want to sync. Such as:

    $ git add README.md

  • Add Comment

    $ git commit -m "注释内容"

  • Establish an association with a remote github repository

    The remote warehouse address is the new project address that you just added on GitHub https://github.com/user name/project name. Git

    $ git remote add origin https://github.com/用户名/项目名.git

  • Sync to a branch of a new project in remote GitHub (default is General Master)

    $ git pull origin master

  • Upload Warehouse to GitHub

    $ git push origin master

    If the following error occurs:

    ![rejected] master -> master (non-fast-forward)

    The reason is that there is already a part of the code in the remote GitHub repository, so it doesn't allow you to overwrite your code directly. There are 2 workarounds:

    1. Force overwrite, which forces your local code to replace the content in the remote GitHub repository:

      $ git push --force origin master

    2. Fetch the content from the remote GitHub repository first and then merge and push

      $ git fetch

      $ git merge

      $ git push origin master

  • Refresh GitHub page and OK.

Use Git to upload local projects to github/coding/code cloud

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.