Git uploads local items to GitHub

Source: Internet
Author: User

git software: https://git-scm.com/download/

1. Build a project on GitHub
After logging on to GitHub, you can find a button "New Repository" in the right-hand side, click on it, fill in the project name, description and URL after you can create, then a prompt page, write down a similar [email protected]:xxx/ Xxx.git address, this is the address of your project.

2. Configure Git and upload code

If it is under Windows, choose Git Bash, complete all git config--global user.name "Yuanhai" on the command line

git config--global user.email "[Email protected]"

Start generating keys and commit keys below

ssh-keygen-t rsa-c " [email protected] "

First open the key to save the location, there will be three files, find Id_rsa.pub, with a text editor open, copy all the characters inside. Go to GitHub and find account Settings in the upper right toolbar. On this page there is an SSH public keys tab, select Add another public key. Title can be filled with a random, key paste just the character, submit.

Find yourself sharing the uploaded code folder, right click to choose Git Bash, or go to this folder in Git bash. Build a warehouse:

Git init

Select the files to add to the warehouse:

git Add.

In general, if you want to share all the code in this folder, add "." After add, the example above is this, if you pass the specified, only need to put "." To the file name, and now just select the files to be added to the warehouse, the following is added into the warehouse:

Git commit-m ' Baidu news crawler '

Git commit just commits to the local repository, and the remote repository has no impact

-M followed by a parameter, indicating that the code submitted to GitHub, will be displayed in the code file information on this note, such as Baidu News crawler

It took so long to start uploading the local repository to GitHub, and the following two lines of command fix the problem:

To add a remote address:

git remote add origin [email protected]:quantmod/javacrawl.git

This [email protected]:quantmod/javacrawl.git is the address above which the created item is generated

After adding to the. Git, open config, there will be more than one remote "origin" content, this is just added to the remoting address, you can also directly modify the config to configure the remote address.

Upload to GitHub

Git push-u Origin Master

If you enter GIT push Origin master
Tip error message: error:failed to push som refs to ....
The solution is as follows:
1. First enter Git pull Origin master //Start the remote server github file down
2. Re-enter GIT push Origin master
3. If an error occurs FATAL:COULDN ' t find remote ref Master or fatal: ' Origin ' does not appear to be a git repository and fatal:could not Read from remote repository.

4, you need to re-enter [email protected]:quantmod/javacrawl.git

Git uploads local items to GitHub

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.