Use git tools under Windows to upload code to GitHub for a pit record

Source: Internet
Author: User
Tags using git

Use git tools under Windows to upload code to GitHub to record background
    • Since previously contacted projects are version control through SVN, now the company projects using Git, plus they usually have a practiced hand small project, while the weekend try to upload the project to their own GitHub to do a management, but also when familiar with the operation of Git, although it is simple operation, because has been not very familiar, So it took a little bit of effort to make a note of some of the notes.

      First step to download git
    • Because it's a Windows-only operation, you're downloading a version of Windows Git:
      URL is https://gitforwindows.org

      The second section creates the local warehouse
    • 1, find their own project directory, of course, you can also find another place to enter the selected folder:
    • 2, after installing Git, in the folder right-click can see the relevant menu git, such as

  • 3. ClickGit Bash Here
  • 4. Command operation in a black window that pops up
    "The above 3-4 steps can also be directly in the CMD operation, here does not repeat"

    • Initialize the current folder and use this folder as a local git repository
      • $git Init
    • After initialization, set up a global account, equivalent to a local git warehouse account registration, future submission code can explain the submitter's information
      • $git--global user.name "Xujie"
      • $git--global user.email "[email protected]"
    • Put all the code under the folder to git management, because I directly select the project code of the workspace, so directly all submitted, no ignore processing, there are other requirements can refer to other blogs have time to organize
      • $git Add *
    • Submit all the code under the folder to the local repository, in fact this is if your workspace and the local warehouse is not in one place (I directly use the work space of the code as a local repository), you need to add the changed file to the local repository, it can be said to be a staging area bar, The next step is to submit to the remote repository all the modifications or newly added code that the local repository or staging area has prepared to commit.
      • $git commit-m "Push all the My code to my github!"
    • Associating a local warehouse with a remote warehouse
      • $ git Remote add origin XXX remoting address xxx
    • to push the local warehouse code to the remote repository
      • $ Git push-u Origin Master
          • If this is the first commit, there will be an error:

              git Could not read from remote repository.
             Sure you have the correct access rights.  
          • This error is due to the fact that the local and remote repositories have a common key to secure the connection at the time of the pairs tuples repository connection.
          • workaround :
          • Enter the command, knock, and then hit three times enter (this three times the enter actually skipped the process of entering the password, This password is the password of each subsequent submission, not GitHub password, for convenience, here directly do not enter, in the future to submit to the remote warehouse when the password is not entered, and then according to the address shown on the screen Open directory (such as):
            • $ Ssh-keygen-t rsa-c "[email  Protected] "
          • Here Choose the second option, open in Notepad, recommend using notepad++ to open, and then copy the full text.
          • open GitHub, select "Settings" in the upper right corner

          • Click on the left "ssh and GPG keys"

          • upper right Corner "New SSH Keys"
          • the title to fill out a random, copy the key paste to the bottom of OK.
    • It's time to $git push -u origin master do it again Will not be an error.
In the cmd Black window operation SSH, if cannot find ssh this command, because the system environment variable did not find "Ssh-keygen.exe" This file, only need to search this file locally, and then add the path of this file to the "path" environment variable is OK,.

Use git tools under Windows to upload code to GitHub for a pit record

Related Article

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.