Uploading items to GitHub under Windows

Source: Internet
Author: User
Tags git client

First of all, we must have patience. It's interesting to see a whole bunch of command lines (not really a bunch of them) and not to be bored, and finally, when you successfully upload your project, the result of that victory. I first write a blog, do not spray.

I write is the main process, details also please visit Liaoche Teacher's official website: git tutorial-Liaoche's official site

Get ready to work on installing Git

Download from Https://git-for-windows.github.io and then install by default option.
After the installation is complete, find Git Bash in the Start menu and pop out a command-line window that shows that the GIT installation was successful!

Configure the machine name and email address

command-line input in git bash open

" Your Name " " [email protected] "

Note the –global parameter of the git config command, which uses this parameter to indicate that all git repositories on your machine use this configuration, but you can also specify a different user name and email address for a particular repository.

Configuring SSH

Because the transfer between your local git repository and the GitHub repository is encrypted via SSH, a bit of setup is required:

1th step: Create SSH Key. In the user home directory, see if there is no. ssh directory, if there is, then look at this directory there are no Id_rsa and id_rsa.pub these two files, if already have, can jump directly to the next step. If not, open the shell (open git Bash under Windows) and create SSH Key:

" [email protected] "

You need to change the email address to your own email address, and then return to the default value, as this key is not used for military purposes, so there is no need to set a password.

If all goes well, you can find the. SSH directory in the user's home directory, there are Id_rsa and id_rsa.pub two files, these two are SSH key key pair, Id_rsa is the private key, can not be leaked out, Id_rsa.pub is the public key, can be assured to tell anyone.

2nd step: Add SSH key. Log on to GitHub and open the "Account Settings", "SSH Keys" page:

Then, click "Add SSH Key", fill in any title, paste the contents of the Id_rsa.pub file in the Key text box:

Click "Add Key" and you should see the Key already added:

Why does GitHub need SSH key? Because GitHub needs to recognize that your push submission is actually pushed by you, not someone else impersonating it, and Git supports the SSH protocol, so if GitHub knows your public key, you can confirm that only you can push it.

Of course, GitHub allows you to add multiple keys. Assuming you have a number of computers, you can submit them at the company in a moment, and at home, just add each key to GitHub and push it to GitHub on every computer.

Finally, friends can see the Git repository, which is hosted on GitHub for free (but only you can change it). So don't put sensitive information in it.

If you don't want others to see the Git repository, there are two ways to do it, one for the intersection protection fee, and for GitHub to turn the public repository into private so that others can't see it (unreadable and not writable). Another way is to do it yourself, take a git server, because it is your own git server, so others are invisible. This method we will talk about later, quite simple, the company internal development necessary.

SSH key only needs to be configured once, then uploading the project will not need to be configured again.

Uploading a local project

When the SSH installation is complete, you can start uploading your local project.

The following 3 images are the command line to be entered:

Detailed steps:

1. Open git Bash

If you've already installed a git client, right-click on the item you want to upload to find git Bash here

2. Follow the steps to enter the command line to upload the project

(If you are using a Windows system, to avoid all kinds of inexplicable problems, make sure that the directory name (including the parent directory) does not contain Chinese)

Turn this directory into a repository that git can manage with the git init command

$ git init

View the submission status of the current project directory

At this point, if the item has no add to staging area or commits, it will be displayed in a red font

$ git status

Add a file or directory to staging area

The file behind the add is the red file or directory shown in the previous step and can be added directly
After executing the Add statement, after executing the "$ git status", you can find that the file you just add has become a green font.

Note Filter The following files (do not need add)
Eclipse Please filter:
*.class
*.apk
bin/
gen/
. settings/
proguard/

Android Studio Please filter:
build/
. idea/
. gradle/
*.iml
Local.properties

$ git Add. classpath$ git Add. Project$ git Add. settings/$ git add bin/$ git add src/

Submit a file or directory to a local warehouse

The content on the back of-m represents the explanatory text of this submission
The current location is simply to store the project to the local warehouse, and then to connect to the remote repository and upload

" Add Project "

To add a remote library

Create a project with the same name on GitHub

Click Create Repository, you will find two local post prompts, respectively copy (here I choose SSH, choose HTTPS also can)

Associating the local library with GitHub

git remote add origin [email protected]:wanganan/shipei.git

Submit Project to GitHub
committing local code to the server
-U represents the first commit of the project and is submitted later by the command "$ GIT push origin master" can be submitted

Git push-u Origin Master

Submit Complete

Wait a few seconds after push to see "Writing objects:100% (10/10), 3.46 KiB | 0 bytes/s, done.
"It means the submission was successful.

When you reopen your project on GitHub, you can see that your project has been uploaded. How, is not very happy Ah!

Now that the GitHub upload is complete, thank you for viewing

Attention:

Here's a very problem with the pit Daddy, that is, after Git remote add origin [email protected]:wanganan/shipei.git may have such error fatal:remote origin already ex Ists.

This situation is because your project has been linked to a remote library, the solution is as follows

$ git Remote RM origin

The meaning of this sentence is to remove the project from the remote connection.
This time in git remote add origin xxx will not error.

Original: 52638503

Uploading items to GitHub under Windows

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.