GitHub Project upload and clone

Source: Internet
Author: User

1. Go to git website https://git-scm.com/to download git first;

2. Create a new folder on the desktop, such as project, and create any new files in the folder such as index.html;

3. Open the folder, press and hold shift+ right button, click Git Bash here to open the Command line window;

4. First create the warehouse: Enter the command git init enter, you will find that the current directory is more than one .git directory, this directory is git to track the management of the repository, it is OK not to modify the directory inside the file, otherwise it will destroy the GIT repository;

5. Configuration information: git config–global user.name "name" git config–global user.email "email", respectively, write your name and mailbox;

6. Create an SSH KEY. First look at the C-drive user directory there is no. ssh directory, some words see there is no Id_rsa and id_rsa.pub these two files, have jumped to the next step, did not create by the following command: ssh-keygen-t RSA-C "yourema[ Email protected] "and then return all the way. Until a similar digital graphic appears to be successful, you will find the Id_rsa and id_rsa.pub two files in the user's. ssh directory, respectively, the private key and the public key;

7. Login to GitHub, find the icon in the upper right corner, open the settings in the inside, then select the SSH and GPG keys inside, click on the new SSH key in the upper right corner, then fill in the title, then put the id_. Rsa.pub inside the content copied to the title under the Key Content box, and finally click on the Add SSH key, so that the completion of the SSH key encryption;

8. Create a git repository on GitHub. Can be created directly from the new repository, such as I created a project warehouse, write the name, description, click Create repository below the creation is successful;

9. After creating a git repository on GitHub, you can associate it with the local repository, which can be entered at the command line of the local project repository, depending on the prompt to create a good git repository page: git remote add origin [email protected] github.com/name/project.git

(Remember that name and project write your own name, item name, the default is the HTTPS protocol, you can switch freely, click on the Clone or download, click on the use SSH below to switch)

10. After the connection, we can push all the contents of the local library to the remote repository, add the content to the warehouse, and enter it at the command line of the local project warehouse: Git Add. (. To add all the files to the warehouse, you can also write the file name to add the replacement point, add a space);

11. Commit the project to the repository with git commit: Git commit-m "Here is the present comment content",-m for comment content, can not write, but in the development perspective, preferably written;

12. Push all the contents of the local library to the remote Repository (GitHub): Git push-u Origin master, because the new remote warehouse is empty, so add-u to this parameter, and so on the remote repository inside the content, The next time you upload content from the local repository, you do not need-u, direct git push Origin master;

13. Wait a moment, upload the success, then re-refresh the GitHub page into the newly built warehouse inside will find that the original empty project has a index.html file, at this time the project has been successfully uploaded;

14. In addition, there is a pit to pay attention to, that is, in the 8th step above the creation of the remote repository, if you check the Initialize this repository with a readme (is to create a repository automatically when you create a readme file), So in the 13th step, when you push the local repository content to the remote repository, you will report a failed to push some refs to [email protected]/name/project.git error. This is because the Readme file in the newly created repository is not in the local repository directory, and the remote repository content can be pulled to the local repository using the following command: Git pull--rebase Origin master, then Git push origin Master will be successful.

15. Cloning of a remote repository: After creating a new remote repository, create a new local folder locally and then execute the command: Git clone [email protected]:name/ Project.git, after execution completes, you can see the same folder in the local directory as the remote repository, that is, the clone succeeds.

Summary: In fact, only the following steps will be able to upload local projects to GitHub

1, create a local repository (ie folder), through the command: Git init to turn it into a git repository;

2, use the command:git config–global user.name "name" git config–global user.email "email" Configuration of personal information (first time use configuration, subsequent configuration is not necessary);

3, copy the project into this folder, and then through the command: Git Add. Add the project to the warehouse;

4, then through the command: git commit-m "comment content" to submit the project to the warehouse;

5. After setting the SSH key on GitHub (first use), create a new remote repository and associate the local repository with the remote repository via git remote add Origin https://github.com/name/project.git;

6. Finally through the command: Git push-u origin master pushes the project of the local repository to the remote repository (that is, GitHub);

7, by executing the command in the local warehouse: Git clone [email protected]:name/project.git to clone the remote repository content locally.

Note: When not in use for a long time, feel all the steps are right but still will be able to sure you with the correct access rights and the repository exists, you can delete the. SSH directory and re- Configure the name mailbox, re-create the SSH key to generate the. SSH directory, and then pull again to push, which may solve the problem.

GitHub Project upload and clone

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.